Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/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?

like image 275
mindless.panda Avatar asked Dec 03 '25 13:12

mindless.panda


1 Answers

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.

like image 116
Andy Mortimer Avatar answered Dec 05 '25 07:12

Andy Mortimer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!