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 certainly make ourProgramEase of use.
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 "; // Program name to be executed P. startinfo. useshellexecute = False ; P. startinfo. redirectstanderinput = True ; // May accept input from the caller P. startinfo. redirectstanderoutput = True ;// The caller obtains the output information. P. startinfo. createnowindow = True ; // Do not display the program window 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 ();
BelowCodeThen 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.
Conclusion