Share via


Source プロパティ

スクリプト エラーの原因となった COM オブジェクトを識別します。

Object.Source

引数

  • Object
    WshRemoteError オブジェクトです。

解説

Source プロパティは文字列を返します。

使用例

次のコードは、スクリプト エラーの原因となった COM オブジェクトを 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 & vbCrLf & "Source: " & theError.Source
    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 + "\nSource: " + theError.Source);
    WScript.Quit(-1);
}

参照

WshRemote オブジェクト | WshRemoteError オブジェクト | Description プロパティ | Line プロパティ | Character プロパティ| SourceText プロパティ | Number プロパティ