Click to See Complete Forum and Search --> : run command from c#.net windows application
daimous
Jul 24th, 2006, 07:57 PM
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!!
jmcilhinney
Jul 24th, 2006, 08:10 PM
// 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.
daimous
Jul 24th, 2006, 08:37 PM
THanks a bunch!!!
conipto
Jul 25th, 2006, 08:35 PM
Also, you can use the /C switch of cmd.exe to exit upon completion..
Process.Start("cmd", "/C " + "your command here");
Bill
wossname
Jul 26th, 2006, 06:56 AM
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");
wossname
Jul 26th, 2006, 06:57 AM
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 :D
Shuja Ali
Jul 26th, 2006, 07:00 AM
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 ;)).
tracernet_v2
Aug 14th, 2006, 02:00 AM
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... ;)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.