I am writing a batch file, in which I call an EXE to execute. Now, statements after the call to the EXE should not execute till the EXE completes its execution. How can I do it in the batch file (on Windows)?
You can use
PAUSE
In batch scripting, but I don't understand your question.
The statements in a batch file are executed sequentially. So if your batch file looks like:
first.exe
next.exe
Next is executed if first is completed.
It depends on how the .exe works. I'm afraid I don't have all the technical details or terminology, but some .exe files will return control of the session immediately after they've started, while others won't return control until after the program has terminated.
The second case is easy as the commands late in the file won't execute until the former have completed, so I'll assume you're facing case #1.
An easy workaround/hack if the execution takes (approximately) the same amount of time every time it runs is to use a ping command with a delay.
PING 127.0.0.1 -n 1 -w 120000 >NUL
This will force the ping command to run once with a 120000ms (2 min) delay.
There's also a good article on a more complex (but more reliable method) on fpschultze.de with a much more detailed explanation. In short you query the task list searching for the executable you're waiting for. As soon as it's not there you carry on with the batch file. It also uses the ping method, but in a different manner.
You could use the "start" command with parameter /wait use start /? on commandline for details.