Windows Script Host  

Status Property (WshScriptExec)

Provides status information about a script run with the Exec() method.

Object.Status

Arguments

Object
WshScriptExec object.

Remarks

The Status property is used when a program is run asynchronously.

Return Values

The Status property returns a value from an enumerated type.

WshRunning ( = 0)
The job is still running.
WshFinished ( = 1)
The job has completed.

Example

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

[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
[JScript]
var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec("calc");

while (oExec.Status == 0)
{
     WScript.Sleep(100);
}

WScript.Echo(oExec.Status);

See Also

Exec Method | WshScriptExec Object