@ECHO OFF
IF "1"=="1" CALL :ADDHOST & echo 1:[%ERRORLEVEL%]
CALL :ADDHOST & echo 2:[%ERRORLEVEL%]
PAUSE
EXIT
:ADDHOST
EXIT /B 3
Output:
[1]:0
[2]:3
Press any key to continue
How can I get the correct exit code ( 3 ) when call something inside the if block?