Windows – How to display console output when running program from command prompt

command linewindows 7

In Windows, when my program starts up from the command line, it displays a window, and on the command prompt it lets me enter another command. It is essentially the Linux equivalent of

./myprogram.exe &

Now, I don't want this. I want to see my console output. Is there any command line argument or some other way to block command prompt from giving me another prompt until the program terminates?

Best Answer

  • start /wait "" myprogram.exe
    

    The empty string "" is the window title. It isn't really needed as I have it written, but it is a good idea to include it. It becomes important if your executable program path requires enclosing quotes due to spaces or other special characters, in which case the program will be mistakenly treated as the window title unless a quoted title string precedes it.

    There are a number of options with the START command. Type START /? from a command prompt to get help.

    Note that some Windows programs launch additional processes that do the real work, and the initial process terminates. START /WAIT would not help with such a program.