How can I terminate the whole main program if inner loop has any issue using batch command? Below is my code.
Here I need to exit from main outer loop if value found in inner loop is X, but currently my code is getting exit from inner loop only.
For %%A in (alpha beta gamma) DO (
Echo Outer loop %%A
Call :inner
)
Goto :eof
:inner
For %%B in (U V W X Y Z) DO (
if %%B==X ( exit /b 2 )
Echo Inner loop Outer=%%A Inner=%%B
)
exit /b 1
Output : it should be like below only.
Outer loop alpha
Inner loop Outer=alpha Inner=U
Inner loop Outer=alpha Inner=V
Inner loop Outer=alpha Inner=W
if ErrorLevel 2 goto :EOFafter thecallcommand line...