What exactly happens when a .NET console application starts?
In the process explorer, when starting the exe I am wondering why I cannot see a “cmd.exe” process as a parent process for the console application. What exactly is displayed then?
Is there a way to replace the “default” console window by another one? I guess this would mean modifying the “console subsystem”.
Creating a GUI application instead of a console application is not an option as I do not have the source of all possible tools.
Observation:
- With Mono and Linux, I have no issue at all regarding this and my test app!
- The font used has an influence, I cannot find a font that fits for everything (even with asia pack installed)
- Tweaking (Changing font, sizes, …) in registry at
HKEY_CURRENT_USER\Consoleis having an impact and can be defined per executable.
You don’t need
cmd.exeto have a console window, any executable with the correct header flag will cause Windows to create a console for it, or connect to the console window of its parent process if its parent has one.Only by:
AllocConsoleto create a console. (Included for completeness, won’t apply here if you cannot rebuild the executable).1CREATE_NEW_CONSOLEflag passed toCreateProcess.21
Editbin.execan change the flag (editbin /subsystem:WINDOWS), but the application would then need to callAllocConsole.2 It is not clear if the
CreateNoWindowproperty ofProcessStartInfoserves the same function forProcess.Startin .NET. If it does this intermediary could be written in .NET, but a native solution would be considerably lighter weight—in such a short program having to load .NET will significantly slow things down.