WshRemoteError オブジェクト

Cc364373.wsWshRemoteErrorObject(ja-jp,MSDN.10).gif

リモート スクリプト (WshRemote オブジェクト) がスクリプト エラーが原因で終了したときのエラー情報へのアクセスを提供します。

解説

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

WScript.DisconnectObject RemoteScript

Sub remote_Error
    Dim theError
    Set theError = RemoteScript.Error
    WScript.Echo "Error " & theError.Number & " - 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);
}

WScript.DisconnectObject(RemoteScript);

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

プロパティ

Description プロパティ | Line プロパティ | Character プロパティ | SourceText プロパティ | Source プロパティ | Number プロパティ

参照

WshRemote オブジェクト