How do I get the application exit code from a Windows command line? -
i running program , want see return code (since returns different codes based on different errors).
i know in bash can running
echo $?
what do when using cmd.exe on windows?
a pseudo environment variable named errorlevel
stores exit code:
echo exit code %errorlevel%
also, if
command has special syntax:
if errorlevel
see if /?
details.
example
@echo off my_nify_exe.exe if errorlevel 1 ( echo failure reason given %errorlevel% exit /b %errorlevel% )
warning: if set environment variable name errorlevel
, %errorlevel%
return value , not exit code. use (set errorlevel=
) clear environment variable, allowing access true value of errorlevel
via %errorlevel%
environment variable.
Comments
Post a Comment