Windows Script Host  

WshScriptExec Object

Exec MethodWshShell Object

Provides status information about a script run with Exec along with access to the StdIn, StdOut, and StdErr streams.

Remarks

The WshScriptExec object is returned by the Exec method of the WshShell object. The Exec method returns the WshScriptExec object either once the script or program has finished executing, or before the script or program begins executing.

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);

Properties

Status Property | StdOut Property | StdIn Property | StdErr Property

Methods

Terminate Method

See Also

WScript Object | Exec Method