Exiting batch with `EXIT /B X` where X>=1 acts as if command completed successfully when using && or || operators between batch calls

前端 未结 4 739
借酒劲吻你
借酒劲吻你 2020-12-09 04:26

I\'m trying to chain a series of .bat files using the EXIT /B X command to return success or failure and && and || for conditi

4条回答
  •  猫巷女王i
    2020-12-09 05:12

    It works as it should when using call to execute batch scripts containing an exit statement:

    C:\>echo @EXIT /B 1 > a.bat
    
    C:\>call a.bat && echo yes
    
    C:\>call a.bat || echo yes
    yes
    

    By the way, it says wrongly on Microsoft docs:

    Call has no effect at the command prompt when it is used outside of a script or batch file.

提交回复
热议问题