How to make a Windows batch file pause while an executable is executing?

I am writing a batch file in which I call the EXE to execute. Now instructions after calling the EXE should not be executed until the EXE completes execution. How to do this in a batch file (on Windows)?

+6
windows batch-file
source share
6 answers
START /WAIT First.exe START /WAIT Second.exe 
+13
source share

It depends on how .exe works. I’m afraid that I don’t have all the technical details or terminology, but some .exe files will return session control right after they start, while others will not return control until the program terminates.

The second case is simple, because the commands at the end of the file will not be executed until the first ones are completed, so I assume that you are faced with case No. 1.

An easy workaround / hack, if the execution takes about the same amount of time each time you start it, use the ping command with a delay.

 PING 127.0.0.1 -n 1 -w 120000 >NUL 

This will cause the ping command to run once with a delay of 120,000 ms (2 min).

There is also a good article on a more complex (but more reliable method) on fpschultze.de with a much more detailed explanation. In short, you are requesting a list of tasks that are looking for the executable that you expect. Once this is not the case, you continue with the batch file. He also uses the ping method, but in a different way.

+7
source share

The statements in the batch file are executed sequentially. Therefore, if your batch file looks like this:

 first.exe next.exe 

Further it is executed if it is completed.

+6
source share

You can use the "start" command with the / wait option to use start /? on the command line for details.

+4
source share

Here is a very simple process. Just keep the next line waiting 10 seconds, and then continue with the other commands ...

TIMEOUT /T 10

That is all you need. I hope you enjoy my technique.

+2
source share

you can use

 PAUSE 

In a batch script, but I do not understand your question.

0
source share

All Articles