bat1 exec bat2(exit 1) , End together
Posted: 20 Jul 2020 21:42
I want to get the exit code of 'bat2'
But after 'bat2' ends, 'bat1' ends with it
---bat1----
--bat2----
But after 'bat2' ends, 'bat1' ends with it
---bat1----
Code: Select all
call "command" > result.txt
call bat2
echo %ERRORLEVEL% ::Not executed
PAUSE ::Not executed
Code: Select all
@echo off
SET RESULT=
for /f "delims=" %%a in (result.txt) do call :CallBack "%%a"
GOTO End
:CallBack
echo %1
SET RESULT=%RESULT%%1
GOTO :EOF
:End
SET CODE=1
(echo %RESULT% | findstr /i /c:"Complete" >nul) && (SET CODE=0) || (SET A=1)
echo %CODE%
exit %CODE%