I really don't know how to fix this, but I know why this works.
You set
UseShellExecute=false;
The core of cmd.exe is equal to the Windows Command Processor , so executing using the Windows shell creates new console windows that are terminals, whose input is processed by cmd.exe, and the output is sent to the terminal.
If you set UseShellExecute=true , a window will appear, but you cannot redirect input and output, and this is due to how it works, as I described in the previous paragraph
EDIT: The most important part: you wrote the "process window"; Console type processes do not have WINDOW at all
source share