0
Windows 7 x64 시스템에서 배치 파일을 사용하여 프로그램을 실행 한 다음 프로세스의 종료 코드를 테스트하고 그 출구 코드. 예 :배치 파일에서 ERRORLEVEL을 테스트하면 예상 결과가 반환되지 않습니다.
@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%
예상되는 동작을 배치 파일에서 가져 오려면 어떻게해야합니까? 오류 수준이 0 이상이기 때문에
, 그것은ERRORLEVEL 0
을 먼저 평가
생각으로