I've got a batch file that executes a program along with sequential (numbered) macros and calls another batch file that monitors when it is finished before it begins the next iteration. I can't use Start /wait or other "ordering" commands when launching the program because it is started with a batch file and syntax that I can't avoid having to use. Once this loop is finished (after the program has opened and closed ~120 times for the typical usage pattern), I need to open it once more and run a different, non-sequential macro, but it fails once the loop has completed.
for /l %%x in (1,1,120) do (
echo %%x
"C:\File Path\ProgramStart.bat" -macro "C:\File Path\MyScript%%x.txt"
timeout 3
start /wait OpenChecker.bat )
"C:\File Path\ProgramStart.bat" -macro "C:\File Path\AnotherScript.txt"
For the sake of completeness, here is OpenChecker.bat:
:check
tasklist /FI "IMAGENAME eq Program.exe" 2>NUL | find /I /N "Program.exe">NUL
if "%ERRORLEVEL%" NEQ "0" exit
TIMEOUT 5
goto check
Despite all of the variations I've tried (both in finding a method that works for the extra-finicky program and changes in syntax in each batch file), I can't seem to get the instance of Program running AnotherScript (or anything else for that matter) to run. Thanks.