I'm trying to store the ERRORLEVEL
environment variable into a a local batch variable. But it always turns out to be 0
.
CALL foo.exe
SET LEVEL=%ERRORLEVEL%
IF ERRORLEVEL 1 (
SET /A ERRORCOUNT=ERRORCOUNT+1
) ELSE (
SET /A OK=OK+1
)
ECHO/ >> logtemp.txt
ECHO ** EXIT %LEVEL% *******************************
I have tried to ECHO %ERRORLEVEL%
but it always print 0
too.
foo.exe
is generating an error and it can be seen by ECHO %ERRORLEVEL%
from the command prompt and the ERRORCOUNT
is updated correctly.
ERRORLEVEL
environment variable, the if ... else is working fine. The problem is to setLEVEL
to theERRORLEVEL
environment variable value soECHO %LEVEL%
will print the environment variableERRORLEVEL
for theCALL
. – Tinstone