The CMD command line of MS is an important operation interface. Some functions that are not easy to complete in C # can be easily implemented by using a few simple commands in CMD, if you can complete the CMD Window Function in C #, it will make our program much easier.
The following describes how to use the cmd.exe program in the C program without displaying the command line window interface.
As follows:
System. Diagnosties. Process p = new System. Diagnosties. Process ();
P. StartInfo. FileName = "cmd.exe"; // name of the program to be executed
P. StartInfo. UseShellExecute = false;
P. StartInfo. RedirectStanderInput = true; // the input information from the caller may be accepted.
P. StartInfo. RedirectStanderOutput = true; // the output information is obtained by the calling program.
P. StartInfo. CreateNoWindow = true; // The program window is not displayed.
P. Start (); // Start the program
// Send the input information to the CMD window:
P. StanderInput. WriteLine ("shutdown-r t 10"); // restart after 10 seconds (C # may be hard to do)
// Obtain the output information of the CMD window:
String sOutput = p. StandardOutput. ReadToEnd (); with the following code, you can operate CMD without knowing it. In short, the Process class is a very useful class, it is very convenient to use third-party programs to expand the C # function.