确定脚本中有错误的行。
Object.Line
Line 属性返回一个不带符号的长整型数。
请注意,有些错误不发生在特定行。例如,考虑错误 Expected End If。在这种情况下,没有任何行(缺少代码行)。此时,Line 属性返回零 (0)。
下面的代码演示 WshRemoteError 对象如何展示发生错误的行。
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
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);
}
WshRemote 对象 | WshRemoteError 对象 | Character 属性 | Description 属性 | Line 属性 | SourceText 属性 | Number 属性 | Source 属性