|
-
Jul 24th, 2006, 07:57 PM
#1
Thread Starter
Fanatic Member
run command from c#.net windows application
hi guyz!!! i have a question. How can I run a windows command like 'Runas','dir','net user', etc...using c# .net windows application. thanks in advance!!
-
Jul 24th, 2006, 08:10 PM
#2
Re: run command from c#.net windows application
Code:
// Run a command prompt with your desired command.
Process.Start("cmd", "your command here");
You should look up the Process class, the Process.Start method and the ProcessStartInfo class for more information.
-
Jul 24th, 2006, 08:37 PM
#3
Thread Starter
Fanatic Member
Re: run command from c#.net windows application
-
Jul 25th, 2006, 08:35 PM
#4
Re: run command from c#.net windows application
Also, you can use the /C switch of cmd.exe to exit upon completion..
Code:
Process.Start("cmd", "/C " + "your command here");
Bill
-
Jul 26th, 2006, 06:56 AM
#5
Re: run command from c#.net windows application
You don't need the "cmd" (in my experience) and you can also stick all your args in with the program name in one string too.
Process.Start(@"rasdial.exe nokia123 /disconnect");
I don't live here any more.
-
Jul 26th, 2006, 06:57 AM
#6
Re: run command from c#.net windows application
Also if you use a ProcessStartInfo object then you can tell it to CreateNoWindow, so you don't get any annoying flashing cmd prompts spoining your nice GUI
I don't live here any more.
-
Jul 26th, 2006, 07:00 AM
#7
Re: run command from c#.net windows application
 Originally Posted by wossname
You don't need the "cmd" (in my experience) and you can also stick all your args in with the program name in one string too.
Process.Start(@"rasdial.exe nokia123 /disconnect");
Well Internal commands like DIR, Type, Prompt, Copy, etc will need CMD (as per my experience ).
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Aug 14th, 2006, 02:00 AM
#8
New Member
Re: run command from c#.net windows application
 Originally Posted by Shuja Ali
Well Internal commands like DIR, Type, Prompt, Copy, etc will need CMD (as per my experience  ).
Ok, but I think you can just use the .NET framework classes intended for them instead of using the CMD...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|