Windows 7 x64システムを使用していて、バッチファイルでプログラムを実行してから、プロセスの終了コードをテストし、その終了コードに基づいてアクションを実行したいと考えています。例えば:
@rem sets the process exit code to 1. should print "success!" actually prints nothing
cmd /c exit 1
if NOT ERRORLEVEL 0 echo success!
@rem prints "success!" as expected
cmd /c exit 1
if errorlevel 1 echo success!
@rem prints "failure!" even though the exit code is 0
cmd /c exit 0
if errorlevel 1 echo failure!
@rem prints "ERRORLEVEL=1" as expected
cmd /c exit 1
echo ERRORLEVEL=%ERRORLEVEL%
バッチファイルから期待される動作を引き出すために何をする必要がありますか?