المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Execute a command in command prompt from C#



C# Programming
05-07-2009, 12:51 PM
Hi!

I would like to execute the command "dir" in the command prompt. But instead manually start the command prompt from the start menu and manually type in "dir" and hit Enter. I would like a console application to do this for me.


This code starts the command prompt
System.Diagnostics.Process.Start("cmd.exe");

How can I pass a command to the command prompt from this point in the code and execute it?

I thought this code did the trick, but no http://www.barakasoft.com/script/Forums/Images/smiley_frown.gif
System.Diagnostics.Process.Start("cmd.exe", "dir");

What am I missing?