欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Windows 腳本宿主  

ConnectObject 方法

將對象的事件源連接到具有給定前綴的函數(shù)。

object.ConnectObject(strObject, strPrefix)

參數(shù)

object
WScript 對象。
strObject
必需。表示要連接的對象名稱的字符串值。
strPrefix
必需。表示函數(shù)前綴的字符串值。

說明

當您要同步對象的事件時,已連接的對象非常有用。創(chuàng)建對象后,ConnectObject 方法將該對象的輸出接口連接到腳本文件。事件函數(shù)由該前綴和事件名稱組成。

示例

下面的示例演示使用 ConnectObject 方法連接WshRemote 對象的錯誤事件。

[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 " & 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);
}

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

請參閱

WScript 對象 | DisconnectObject 方法 | CreateObject 方法 | GetObject 方法