I've made a script (called isPA64.bat) to determine if the executing system is 64-bit (based on this Bear's Log tip):
@echo off
setlocal
set str1=%PROCESSOR_ARCHITECTURE%
set/A sixty4=0
if not x%str1:64=%==x%str1% set/A sixty4=1
endlocal & exit/B %sixty4%
It gets called from another simple batch, named callpa.bat (it could be called directly, too, but this proves that ERRORLEVEL does, indeed, get set appropriately):
@echo off
ver>nul & (call isPA64.bat & if ERRORLEVEL 1 (echo 64-bit & exit/B 1) else (echo not 64-bit & exit/B 0))
Up to this point, this all works fine; however, I must call one of these two from a Python 3.7.2 program. I do this:
import subprocess
print(subprocess.run(["callpa.bat"]))
Simple enough, right? But I haven't been able to figure out how to get a valid return code back, in the python code... Is there a way to assign a variable in the python code to either the "exit"/return code or to the value of ERRORLEVEL, from the cmd.exe shell which executes the outer-level script? ...I can't find a way in the python doc's to do that.