EXITWITHCODE.PB - PB app that exits with an error code
Code: Select all
#ERRCODE = 123
OpenConsole()
PrintN("Exiting with error code " + Str(#ERRCODE))
End #ERRCODE
GETEXITCODE.PB - PB app that runs a program and reads its error code
Code: Select all
OpenConsole()
hRunApp = RunProgram("exitcode.exe", "", "", #PB_Program_Wait | #PB_Program_Open)
PrintN("The program exited with code " + Str(ProgramExitCode(hRunApp))): Input()
Code: Select all
exitcode.exe
@echo The program exited with code %errorlevel%
Code: Select all
#!/bin/bash
./exitcode
echo "The program exited with code $?"