I have looked here
And I understand that
A) Not every program respects it CreateNoWindow request and
B) It requires UseShellExecute=False (default is true).
C) It is meant to indicate whether a window is created. (it won't ever hide the parent window). It's speaking of whether a window is created for the child process. (msdn says 'new window')
D) CreateNoWindow defaults to false.
I am running this from cmd, though clicking play in visual studio illustrates the same behaviour.
I set CreateNoWindow to false so i'd have thought it'd create a new window for the child process.
But it does not.
task manager shows the second instance of cmd.exe but there's still the one window as you can see. Below is the paste from one window. It has loaded the child cmd.exe in the parent window (the one cmd window)
If I set CreateNoWindow to true or false, then it seems to make no difference.
So i'm clearly not getting the example at that msdn link to work.
C:\crp>type aaa.csc
using System.Diagnostics;
class blah{
public static void Main(string[] args) {
Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute=false;
psi.FileName="cmd.exe";
psi.CreateNoWindow=false;
p.StartInfo=psi;
p.Start();
}
}
C:\crp>csc aaa.csc
Microsoft (R) Visual C# Compiler version 4.0.30319.34209
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.
C:\crp>aaa.exe
C:\crp>Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\crp>
UPDATE
It seems it does work. If you open a cmd prompt and run the exe, then in one case it starts cmd.exe within the parent. In the other case it starts a cmd.exe without any window. The behaviour within visual studio seems odd though, see my comment to ephraim's answer. In this question while within visual studio, i'd only tried it with the project set to being a console application, and there a cmd prompt window will always at least flick up. Behaviour is much simpler for a non console application e.g. a winforms application.