Note that most cases it is better to use
start /WAIT
https://ss64.com/nt/start.html
But in a case like the following, with no alternative this snippet can work.
"The above will start the calculator and wait before continuing. However if you replace calc.exe with Winword.exe, to run Word instead, then the /wait will stop working, this is because Winword.exe is a stub which launches the main Word application and then exits."
TIMEOUT /T 10 :: Set timeout for how long it takes to launch the exe you want to monitor SETLOCAL EnableExtensions set EXE=EXAMPLE.exe :while1 FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq %EXE%"') DO IF %%x == %EXE% goto FOUND echo Not running pause goto FIN :FOUND TIMEOUT /T 5 echo Timeout Done goto :while1 :FIN echo THIS IS FIN pause
https://stackoverflow.com/questions/1788473/while-loop-in-batch/1788487#1788487
https://stackoverflow.com/questions/23266509/check-if-a-process-is-running-or-not
https://superuser.com/questions/1293730/start-wait-d-not-working/1293734#1293734
1 Comment
Anonymous