My command takes long to run but I expect that it can finish with error and I want fail fast in the batch loop in this case. How do I produce the error level?
I tried a batch file with exit 1
. But, it closes the parent script regardless if it is called with call raise_error.bat
or simply raise_error
.
I also tried cmd /c exit 1
. This does not close the parent script but following if errorlevel 0 goto exit
and if errorlevel 1 goto exit
both branch to exit. No early exit is taken in case of if errorlevel 2 goto exit
or any larger number. How is it ever possible? I mean, how can I have two error levels at the same time? Aren't values of a single variable they mutually exclusive?
How do I inject the error exit code?