check if command was successful in a batch file

前端 未结 5 982
南方客
南方客 2020-12-04 23:56

How within a batch file to check if command

start \"\" javaw -jar %~p0/example.jar

was successful or produced an error?

I want to u

5条回答
  •  遥遥无期
    2020-12-05 00:02

    Most commands/programs return a 0 on success and some other value, called errorlevel, to signal an error.

    You can check for this in you batch for example by:

    call 
    if %ERRORLEVEL% == 0 goto :next
    echo "Errors encountered during execution.  Exited with status: %errorlevel%"
    goto :endofscript
    
    :next
    echo "Doing the next thing"
    
    :endofscript
    echo "Script complete"
    

提交回复
热议问题