Windows 脚本宿主  

Status 属性 (WshScriptExec)

提供有关用 Exec() 方法运行脚本的状态信息。

Object.Status

参数

Object
WshScriptExec 对象。

说明

Status 属性用于程序异步运行时。

返回值

Status 属性从枚举类型中返回一个值。

WshRunning ( = 0)
作业仍在运行。
WshFinished ( = 1)
作业已完成。

示例

下面的代码运行 calc.exe 并在屏幕上显示最终状态:

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

请参阅

Exec 方法 | WshScriptExec 对象