Wscript.DisconnectObject

The DisconnectObject method disconnects a previously connected object (obj) from Windows Scripting Host. If the specified object is not already connected to Windows Scripting Host, this method does nothing.

Syntax

Wscript.DisconnectObject obj
 

Example

' This code fragment instantiates a fictitious object and 
' connects it to the script file. The script then calls the 
' "SomeMethod" method on the object. 
' If an error called "Event" occurs in the object, then the 
' MyEvent_Event subroutine is called.

Set MyObject = Wscript.CreateObject("SomeObject", "MyEvent")

MyObject.SomeMethod

Sub MyEvent_Event(strName)
        Wscript.Echo strName
End Sub

' When done with the object, disconnect it from the script 
' and then set it to Nothing
Wscript.DisconnectObject MyObject
Set MyObject = Nothing

See Also

Wscript.CreateObject method, Wscript.GetObject method