Windows 脚本宿主  

Error 属性 (WshRemote)

展示 WshRemoteError 对象,它保留有关导致远程脚本过早终止错误的信息。

Object.Error

参数

Object
WshRemote 对象。

说明

Error 属性返回 WshRemoteError 对象。

示例

下面的代码演示 WshRemote 对象的 Error 属性如何展示 WshRemoteError 对象,其中包括行、字符和错误说明。

[VBScript]
Dim Controller, RemoteScript
Set Controller = WScript.CreateObject("WSHController")
Set RemoteScript = Controller.CreateScript("test.js", "remoteserver")
WScript.ConnectObject RemoteScript, "remote_"
RemoteScript.Execute

Do While RemoteScript.Status <> 2 
    WScript.Sleep 100
Loop

Sub remote_Error
    Dim theError
    Set theError = RemoteScript.Error
    WScript.Echo "Error - Line: " & theError.Line & ", Char: " & theError.Character & vbCrLf & "Description: " & theError.Description
    WScript.Quit -1
End Sub
[JScript]
var Controller = WScript.CreateObject("WSHController");
var RemoteScript = Controller.CreateScript("test.js", "remoteserver");
WScript.ConnectObject(RemoteScript, "remote_");
RemoteScript.Execute();

while (RemoteScript.Status != 2) {
    WScript.Sleep(100);
}

function remote_Error()
{
    var theError = RemoteScript.Error;
    WScript.Echo("Error - Line: " + theError.Line + ", Char: " + theError.Character + "\nDescription: " + theError.Description);    WScript.Quit(-1);
}

请参阅

WshController 对象 | WshRemote 对象 | WshRemoteError 对象 | Status 属性 | Execute 方法 | Terminate 方法 | Start 事件 | End 事件 | Error 事件