tags:

views:

45

answers:

3

We have some code that works and it's a Win32 app with a GUI, but I would like to be able to trigger it from the command line as well (silent mode). Is there any easy way to do this? Or do I have to create another project as a command line application?

+1  A: 

c:> notepad.exe

That answer your question?

Noah Roberts
I think you misunderstood the question. I don't want to just open the GUI app from command line. I want to be able to run the program in "silent mode" with no GUI.
Brian T Hannan
+3  A: 

If you want the application to be absolutely invisible, i.e. no window at all, you simply have to skip the part of your application that creates the main window. A normal command line application will create a console window, which will flash on the screen as the application opens and closes.

Mark Ransom
+1  A: 

You can write a small application which start your old GUI application with respect of CreateProcess Windows API. CreateProcess has lpStartupInfo parameter of the type STARTUPINFO or STARTUPINFOEX. If you initialize wShowWindow field of this STARTUPINFO or STARTUPINFOEX to SW_HIDE, then the main Windows of application which will be started will be hidden. You must also set dwFlags of STARTUPINFO or STARTUPINFOEX which includes STARTF_USESHOWWINDOW bit mask.

Such small program starting another program in hidden mode can be also used to start a console application without opening a well known console window.

Oleg