I want to start a process with a batch file and if it returns nonzero, do something else. I need the correct syntax for that.
Something like this:
::x.bat
@set RetCode=My.exe
@if %retcode% is nonzero
handleError.exe
As a bonus, you may consider answering the following questions, please :)
- How to write a compound statement with
if
? - If the application
My.exe
fails to start because some DLL is missing will my if work? If not, how can I detect thatMy.exe
failed to start?
ERRORLEVEL
is exactly what you want. The statement Eduard posted will return TRUE as long as the return code is equal to or higher than the specified value. – Electrotonus