What is the difference between ProcessStartInfo UseShellExecute and CreateNoWindow?

If I were to write a console application that starts another console application as a new process and uses the default values โ€‹โ€‹of "UseShellExecute" and "CreateNoWindow", the result is a new command window next to the console window

UseShellExecute=true and CreateNoWindow=false 

Now, if I use the following, a new window will not be created, but the output of the running process will appear in the application window that launched it:

  UseShellExecute=false and CreateNoWindow=false 

And if I used the following, neither a new window would be created, nor the output of the running process would appear in the window of the launching application:

  UseShellExecute=false and CreateNoWindow=true 

But it seems that "CreateNoWindow" does not work when UseShellExecute = true, and what role does "CreateNoWindow" play when UseShellExecute = true? Is it used only when the application launched as a new process is a Forms application?

+4
source share
1 answer

He does not play any role. The rule is that CreateNoWindow will have an effect only when:

  • You use UseShellExecute = false so that winapi CreateProcess () is used to run the program
  • The program you launched is a console application.

If the application is a native Windows GUI application that creates its own window, you can ask it not to create a visible window with WindowStyle = ProcessWindowStyle.Hidden. However, there are many programs that ignore this request. They should, only a way to stop this through the Task Manager. The next smart choice is ProcessWindowStyle.Minimized

+4
source

All Articles