C # example of calling the Exe program,
When writing a program, you will often use calling executable programs. This article will briefly introduce how C # Calls exe. In C #, Process operations are performed through the Process class. The Process class is in the System. Diagnostics package.
Example 1
Using System. Diagnostics; Process p = Process. Start ("notepad.exe"); p. WaitForExit (); // key. It can be executed only after the external program exits.
The above code can call the Notepad program. Note that if you do not call the system program, you must enter the full path.
Example 2
When you need to call the cmd program, the above call method will pop up a nasty black window. If you want to cancel the configuration, You need to perform more detailed settings.
The StartInfo attribute of the Process class contains some Process startup information.
FileName executable program file name
The Arguments program parameter, which has been entered as a string
Does CreateNoWindow not need to be created?
Whether UseShellExecute requires a system shell call program
These parameters can be used to remove unwanted black screens.
System. diagnostics. process exep = new System. diagnostics. process (); exep. startInfo. fileName = binStr; exep. startInfo. arguments = reverse STR; exep. startInfo. createNoWindow = true; exep. startInfo. useShellExecute = false; exep. start (); exep. waitForExit (); // key. It can be executed only after the external program exits.
Or
System. diagnostics. process exep = new System. diagnostics. process (); System. diagnostics. processStartInfo startInfo = new System. diagnostics. processStartInfo (); startInfo. fileName = binStr; startInfo. arguments = shortstr; startInfo. createNoWindow = true; startInfo. useShellExecute = false; exep. start (startInfo); exep. waitForExit (); // key. It can be executed only after the external program exits.