Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 06-27-2005, 09:24 PM   #1 (permalink)
 
Newb Techie

Join Date: Jun 2005

Posts: 17

zellist

Default Importing cmd into VS.net

Hi guys,

I've got a query to ask. I'm currently research on a new project and is not very familiar with VS.net. I wanna know if I can insert a command from our command prompt into VS.net.

E.g. I've a button on VS.net and a textarea to display the result. Onclick the button; let's say when they click, it will automatically type in a command into the command prompt [e.g. netstat] and the result will display on the textarea.

Is this possible with VS.net? I'll appreciate any help
zellist is offline  
Old 06-28-2005, 10:33 AM   #2 (permalink)
 
Ultra Techie

Join Date: Sep 2003

Location: Bamberg, Germany

Posts: 549

Iron_Cross

Send a message via ICQ to Iron_Cross Send a message via MSN to Iron_Cross Send a message via Yahoo to Iron_Cross
Default

Ok, you'd probably have to use the Process or ProcessStartInfo classes. You'd send in the program "netstat" as the program to execute along with the arguments. You'd also have to add a special argument to redirect the output ("netstat -an > someFile.txt") then on the Process class you'd call the WaitForExit() method. Then you'd open and read all the contents of that file into your text area.

That would probably be the easiest way to do it.

It'd look something like this:
Code:
ProcessStartInfo l_psi = new ProcessStartInfo("Netstat");
l_psi.Arguments = "-an > SomeFile.txt";

Process.Start(l_psi);
Process.WaitForExt();

// Read in the contents of the SomeFile.txt here
// and print it to the text area

__________________

See today\'s Penny-Arcade!(May contain foul lanuage)
Pain is weakness leaving the body.

PM Me for my MSN
Iron_Cross is offline  
Old 06-29-2005, 01:18 AM   #3 (permalink)
 
Newb Techie

Join Date: Jun 2005

Posts: 17

zellist

Default

Hi Cross,

Thanks for your info. So, ProcessStartInfo is something already in the library already? I'll give it a try when i reach home.
zellist is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On