ExitCode Property |
Description
Returns the exit code set by a script or program run using the Exec method.
PowerBASIC Syntax
Remarks
Executables set an exit code when they finish running. This conveys the status information when a process ends. Often, it is used to send an error code (or some other piece of information) back to the caller. If the process has not finished, the ExitCode property returns 0. The values returned from ExitCode depend on the application that was called.
Example [PowerBASIC]
The following example illustrates the use of the ExitCode property. It contains an intentionally wrong argument "dire" to return an exit code <> 0.
#INCLUDE "WSHOM.INC"
DIM pWsh3 AS IWshShell3 DIM pWshExec AS IWshExec
pWsh3 = NEWCOM "WScript.Shell" pWshExec = pWsh3.Exec(UCODE$("%comspec% /c dire")) DO IF pWshExec.Status <> 0 THEN EXIT DO SLEEP 100 LOOP STDOUT "Status: " pWshExec.Status STDOUT "Exit code: " pWshExec.ExitCode
|