Exit in For loop - Windows Command Processor (CMD.EXE)
问题 I am trying to find way to break / exit from FOR loop, if there are any error occured. Below is content of batch file. @echo on set myfile=D:\sample.txt FOR /F "tokens=1,2 delims=," %%i in (%myfile%) do call :process "%%i" :process set recfile=%1% echo %recfile% echo "Step in Test1" echo %errorlevel% pause; exit /B 0 If %errorlevel% NEQ 0 goto :fail1 :fail1 echo "Step in fail1" pause; exit /B 9993 :EOF Sample.txt has multiple records. If there are any error occured then I am expecting to exit