command-linevisual-studio-2005consolesubsystem

/SUBSYSTEM:Windows program will not write to command line


I have a mixed mode C++-CLI program in Visual Studio 2005 that is set to use the /SUBSYSTEM:Windows. Generally speaking it is a graphical application that is launched from its shortcut or through the filetype registered to it.

However, there is a rare occasion where a user will want to run it from the command line with arguments. I can access the arguments just fine, its when it comes to writing to the console, in response to the program being launched from the command line with arguments, where I don't see Console::WriteLine having any effect.

What am I doing wrong?


Solution

  • This one's annoying, I agree. You're not doing anything wrong, it's a quirk of the way Windows is set up.

    It is possible to solve this, at least in some cases, see http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx . I've not come across anybody else who's actually used these methods though.

    Most people IME just create two versions of the executable with different names, one for batch users ("myapp.exe") and one for when it's run from the start menu ("myappw.exe").

    For more information, some of the suggestions at How to output to the console in C++/Windows may be useful.