Running this batchfile from the Windows commandline results in an %errorlevel% of 5 (i.e. running echo %errorlevel%
on the commandline after having executing the batch file prints the number 5):
EXIT /B 5
This is fine.
However, running this batchfile results in an %errorlevel% of 0, no matter what:
sleep 1
EXIT /B 5
I want it to return the error code 5. How can I do that?
Note: If I add sys.exit(13) to the sleep.py (see below), then the second batch file will return with an exit code of 13. So my batch file will return with the exit code of the sleep.py script instead of the exit code specified via the EXIT command (which is strange).
sleep.bat:
sleep.py %1
sleep.py:
import sys
import time
if len(sys.argv) == 2:
time.sleep(int(sys.argv[1]))