Search code examples
c++windowswinapiwin32-process

Creating a process attached to a console but with redirected standard IO handles


I have a command line application that executes other programs according to a user provided script. Some of the executed child processes are cmd.exe running various .cmd scripts. Some of the .cmd scripts are setting the console window title using the title Windows shell command. And here is the problem. If user requests logging of child process' output I use pipes for standard handles to get the output from the child process. However that seems to make the child process not to be attached to the console that my application is running in and thus the title command stops working, stops changing the console window title.

Is it possible to create a process with redirected standard handles but such that is still attached to the parent process' console so that the title command works?


Solution

  • Apparently, all that needs to be done for the child process to be attached to the parent's console is to not use dwCreationFlags |= CREATE_NO_WINDOW;.