Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
372 views
in Technique[技术] by (71.8m points)

c++ - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...