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!!
Printable View
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!!
You should look up the Process class, the Process.Start method and the ProcessStartInfo class for more information.Code:// Run a command prompt with your desired command.
Process.Start("cmd", "your command here");
THanks a bunch!!!
Also, you can use the /C switch of cmd.exe to exit upon completion..
BillCode:Process.Start("cmd", "/C " + "your command here");
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");
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
Well Internal commands like DIR, Type, Prompt, Copy, etc will need CMD (as per my experience ;)).Quote:
Originally Posted by wossname
Ok, but I think you can just use the .NET framework classes intended for them instead of using the CMD... ;)Quote:
Originally Posted by Shuja Ali