I want to use C# to send a command to the shell. I dont want to open an external application I just want to send a command such as the PAUSE command to the shell. It would be much appreciated if someone could tell me how to do this.
I want to use C# to send a command to the shell. I dont want to open an external application I just want to send a command such as the PAUSE command to the shell. It would be much appreciated if someone could tell me how to do this.
You need to look at the System.Diagnostics.Process class..
You can do something like the following to execute a command in the shell. But I don't think this is going to work for the pause command as it is not a file as such. What are you trying to acheive, perhaps there is a better way of doing this?
Code:System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents=false; proc.StartInfo.FileName="calc"; proc.Start();
Well I guess that I could just use Console.ReadLine(); to wait for the user to press enter. I could also write my own code to have the computer wait for the user to press any key so I guess I'll do one of those two things. I also wanted to use it to add some console arguments to an application I wanted to run but I was reading on MSDN and I figured out how to do that with the arguments property of the StartInfo class.