Interactive PowerBasic Forum

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

Title: IWshShell3.Exec Method
Post by: José Roca on July 14, 2008, 07:01:16 AM


The following code illustrates the use of the Exec method:

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