c++command-linec++builder-xe3

After Executing a exe from command line command line should wait for the completion of exe


I have a executable in which some command line options are provided to run it in a silent mode. But when i run the executable from the command prompt with command line options it didn't wait for the completion of executable.

I want that it should wait for the completion of execution of exe.

I don't want to add any other parameter in command prompt. I want to handle this in executable.

Can anyone help?


Solution

  • What you are asking for cannot be handled in the executable. The console is launching the executable and not waiting for it to exit. That is a console issue, not an executable issue. You need to use the console's start command to run the executable so you can use the command's /wait parameter:

    start /wait myapp.exe /silent
    

    Or else use a batch file to run your executable, and then have the console run the batch file. A batch file waits for each command to complete, and the console waits for a batch file to complete.