Batch File Nested For /L Loops and Exiting them
问题 SETLOCAL ENABLEDELAYEDEXPANSION set list=A B C D E FOR %%a IN (%list%) DO ( start %%a.exe > ouput_%%a.txt echo 120, 30 second loops = 60 min FOR /L %%i IN (1,1,120) DO ( REM pause for 30 seconds ping 1.1.1.1 -n 1 -w 30000 > nul echo find the running executable tasklist | findstr %%a.exe > nul REM !ERRORLEVEL! REM exit the script if no executable is found (i.e it has run successfully) if !ERRORLEVEL! equ 1 goto success ) REM kill executable if we haven't exited yet taskkill /f /im %%a.exe