Use start / wait:
:NOTEPAD start /wait notepad.exe IF %ERRORLEVEL% == 0 goto NEXTITEM1 else goto QUIT :NEXTITEM1 start /wait mplayer.exe IF %ERRORLEVEL% == 0 goto NEXTITEM2 else goto QUIT :NEXTITEM2 start /wait explorer.exe IF %ERRORLEVEL% == 0 goto NEXTITEM3 else goto QUIT :NEXTITEM3 REM You get the idea... :QUIT exit
Also, use NT CMD, not BAT (myscript.cmd).
In response to comments, parentheses are removed from the above script around% ERRORLEVEL%. The following looks as expected:
:NOTEPAD start /wait notepad.exe || goto QUIT :NEXTITEM1 start /wait mplayer2.exe || goto QUIT :NEXTITEM2 REM You get the idea... :QUIT exit
A statement after two-pipe execution is executed only if before it completed with an error.
nimizen
source share