Jose's Read Only Forum 2023

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Source Code => Scripting => Windows Script Host => Topic started by: José Roca on July 14, 2008, 10:16:33 PM

Title: IWshExec.Status Property
Post by: José Roca on July 14, 2008, 10:16:33 PM


The following code runs calc.exe and echoes the final status to the screen.

JScript

var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec("calc");
while (oExec.Status == 0)
{
    WScript.Sleep(100);
}
WScript.Echo(oExec.Status);


VBScript

Dim 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


PowerBASIC

DIM 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