Reputation: 1609
Below is the sample logic for setting errorlevel and then checking the errorlevel.
echo setting error based on some condition
set errorlevel=2
if errorlevel 2 (
echo Error logic
)
Expected output was
"Error logic"
Actual output : not printing anything on console
Upvotes: 2
Views: 53
Reputation: 3180
In a nutshell: "You can't just setup ERRORLEVEL variable". One of the way is
echo err = %ERRORLEVEL%
call :set_error_code 123
echo err = %ERRORLEVEL%
exit /b 0
:set_error_code
exit /b %~1
See more on ERRORLEVEL.
Upvotes: 2