I have a program that has stdout and stderr available, so it can and does write important output on these channels. You only see this output when you e.g. launch it from a Windows console window, through typically the command interpreter or Powershell, otherwise obviously you don't have any place you can see said output.
Since this program also works without an attached console window and since it's otherwise a GUI application, I would rather avoid users to be confused about parent or attached console -- the program is best used without one, for all use cases except debugging.
Now, I want to be able to obtain the output nevertheless, even when there is no console window used. I am a big vague on specifics of process file handle management in Windows.
Is there any program available that is designed to launch a program as subprocess, with stdout and stderr redirected to a file or multiple files?
I know that the good old command interpreter and Powershell let you do that, but they only do that with a console window, and I want something that has no such window. A Visual Basic script host, perhaps? Is that still en vogue? Any other solutions?
printfor some other system function that attempts to write to the standard output file. Since the handle isn't normally set up for GUI applications the output does not go anywhere, but that doesn't mean the program doesn't otherwise work -- the calls toprintfdo not throw an exception or anything. I've just written a small GUI application that callsprintf-- nothing appears anywhere but the program isn't halted. If I attach a valid standard output handle, I should at least capture the output. – Armen Michaeli Sep 06 '18 at 10:59SUBSYSTEM:WINDOWSprogram from writing to stdout/stderr (they just don't go anywhere by default). Nor is there anything preventing aSUBSYSTEM:CONSOLEprogram from callingCreateWindowand running its ownGetMessageloop. Those subsystems basically control some default behaviors. Also see https://stackoverflow.com/questions/2627900/what-can-explain-stdcout-not-to-display-anything/2628025#2628025 – jamesdlin Feb 15 '19 at 19:25SUBSYSTEM:CONSOLEprogram that callsGetMessage/TranslateMessage/DispatchMessagein a loop itself. There's nothing magical about the message pump. Or as another example, you can just runeditbin.exeon a Windows program to change it fromSUBSYSTEM:WINDOWStoSUBSYSTEM:CONSOLEand see no difference other than it now attaches to a console. – jamesdlin Feb 15 '19 at 20:42