The following code runs calc.exe and echoes the final status to the screen.
JScriptvar WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec("calc");
while (oExec.Status == 0)
{
WScript.Sleep(100);
}
WScript.Echo(oExec.Status);
VBScriptDim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("calc")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
WScript.Echo oExec.Status
PowerBASICDIM pWsh3 AS IWshShell3
DIM pWshExec AS IWshExec
pWsh3 = NEWCOM "WScript.Shell"
pWshExec = pWsh3.Exec(UCODE$("calc"))
DO
IF pWshExec.Status <> 0 THEN EXIT DO
SLEEP 100
LOOP
PRINT "Status: " pWshExec.Status