Author Topic: IWshExec.Status Property  (Read 3393 times)

0 Members and 1 Guest are viewing this topic.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2530
  • User-Rate: +209/-0
  • Gender: Male
IWshExec.Status Property
« on: July 14, 2008, 10:16:33 PM »

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

JScript
Code: [Select]
var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec("calc");
while (oExec.Status == 0)
{
     WScript.Sleep(100);
}
WScript.Echo(oExec.Status);

VBScript
Code: [Select]
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
Code: [Select]
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