Call Python From Bat File And Get Return Code
Try:
import os
os._exit(ret_value)
You should also check:
- sys.exit()
The windows shell saves the return code in the ERRORLEVEL
variable:
python somescript.py
echo %ERRORLEVEL%
In the python script you can exit the script and set the return value by calling exit()
:
exit(15)
In older versions of python you might first have to import the exit()
function from the sys
module:
from sys import exit
exit(15)