How to break from a .cmd?
Posted: 16 Oct 2024 23:00
I have 1.cmd:
and I have 2.cmd
Output:
I want to exit 2.cmd when first error (a.a) occurs. If I just use EXIT 1.cmd quits - I don't want that.
Please help.
Thanks.
Saso
Code: Select all
@call 2.cmd
@echo HERE-1.cmd
Code: Select all
@echo off
for %%f in (a.a b.b c.c) do call :DOIT "%%f"
echo END-2.cmd
goto :EOF
:DOIT
set errlev=1
if not "%errlev%"=="0" echo ERROR %1.&exit /b
echo TOO FAR
goto :EOF
Code: Select all
c:\>
ERROR "a.a".
ERROR "b.b".
ERROR "c.c".
END-2.cmd
HERE-1.cmd
c:\>
Please help.
Thanks.
Saso