How do I get the application exit code from a Windows command line?

后端 未结 7 845
执笔经年
执笔经年 2020-11-22 02:13

I am running a program and want to see what its return code is (since it returns different codes based on different errors).

I know in Bash I can do this by running<

7条回答
  •  星月不相逢
    2020-11-22 02:54

    If you want to match the error code exactly (eg equals 0), use this:

    @echo off
    my_nify_exe.exe
    if %ERRORLEVEL% EQU 0 (
       echo Success
    ) else (
       echo Failure Reason Given is %errorlevel%
       exit /b %errorlevel%
    )
    

    if errorlevel 0 matches errorlevel >= 0. See if /?.

提交回复
热议问题