リモート スクリプトが途中で終了する原因となったエラーの情報を保持する WshRemoteError オブジェクトを公開します。
Object.Error
引数
- Object
WshRemote オブジェクトです。
解説
Error プロパティは WshRemoteError オブジェクトを返します。
使用例
次のコードは、WshRemote オブジェクトの Error プロパティが WshRemoteError オブジェクトを公開する例です。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 イベント