Get error code from within a batch file

后端 未结 3 1336
被撕碎了的回忆
被撕碎了的回忆 2020-12-05 09:25

I have a batch file that runs a couple executables, and I want it to exit on success, but stop if the exit code <> 0. How do I do this?

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 10:13

    You can also use conditional processing symbols to do a simple success/failure check. For example:

    myProgram.exe && echo Done!
    

    would print Done! only if myProgram.exe returned with error level 0.

    myProgram.exe || PAUSE
    

    would cause the batch file to pause if myProgram.exe returns a non-zero error level.

提交回复
热议问题