SWbemRefresher object

The SWbemRefresher object is a container object that can refresh the data for all the objects that are added to it. Single instances and instance enumerators can be added or removed from the container. The set of added objects, each item represented by an SWbemRefreshableItem instance, can be treated as a collection and enumerated. WMI instances from any class can be added to the SWbemRefresher object. Even if the provider for the instance data is not a high-performance provider, the refresher object can still update the data on the Refresh call. If the data is supplied through a high-performance provider and the AutoReconnect property is TRUE, then the SWbemRefresher object attempts to reestablish a broken connection to the data provider. This object can be created by the VBScript CreateObject call.

The refresh operation can be carried out by calling either the SWbemRefresher.Refresh method or the SWbemObjectEx.Refresh_ method.

Members

The SWbemRefresher object has these types of members:

Methods

The SWbemRefresher object has these methods.

Method Description
Add Adds a new refreshable object to the collection in the refresher object.
AddEnum Adds a new enumerator to the refresher object.
DeleteAll Removes all items from the collection in the refresher object.
Item Returns a specified refresher item from the collection.
Refresh Updates all the items that are contained in the refresher object.
Remove Removes the refresher item object or object set with a specified index from the refresher.

Properties

The SWbemRefresher object has these properties.

Property Access type Description
AutoReconnect
Read-only
Indicates whether the refresher automatically reconnects to a remote provider if the connection is broken.
Count
Read-only
Contains the number of items in the refresher object.

Examples

The following example illustrates creating an SWbemRefresher object, using the Add and AddEnum methods to store a single instance and an enumeration instance, the refreshing of the data, and using the Item property to obtain the SWbemRefreshableItem objects.

' Get namespace connections
set objServicesCimv2 = GetObject("winmgmts:root\cimv2")
set objServicesDefault = GetObject("winmgmts:root\default")

' Create a refresher object
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")

' Add a single object (SWbemObjectEx) to the refresher. The "@"
' is used because _CIMOMIdentification is a singleton class- only 
' one instance exists. Note that the
' SWbemRefreshableItem.Object property must 
' be specified or the SWbemRefresher.Refresh call will fail.

set objRefreshableItem1 = objRefresher. _
    Add (objServicesDefault, "__CIMOMIdentification=@").Object

' Add an enumerator (SWbemObjectSet object)
' to the refresher. Note that the
' SWbemRefreshableItem.ObjectSet property
' must be specified or the SWbemRefresher.Refresh call will fail. 
set objRefreshableItem2 = objRefresher. _
    AddEnum (objServicesCimv2, "Win32_Process").ObjectSet

' Display number of items in refresher and update the data.
MsgBox "Number of items in refresher = " & objRefresher.Count
objRefresher.Refresh

' Iterate through the refresher. SWbemRefreshable
' Item.IsSet checks for whether the item is an enumerator.
for each RefreshableItem in objRefresher
 if RefreshableItem.IsSet then  
    MsgBox "Item with index " & RefreshableItem.Index &_
    " is an enumerator containing "_
    & RefreshableItem.ObjectSet.Count & " processes"
 else  
      MsgBox "Item with index " & RefreshableItem.Index _
          & " is a single object containing WMI version "_
          &  objRefreshableItem1.VersionCurrentlyRunning
 end if
next

Requirements

Requirement Value
Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Header
Wbemdisp.h
Type library
Wbemdisp.tlb
DLL
Wbemdisp.dll
CLSID
CLSID_SWbemRefresher
IID
IID_ISWbemRefresher

See also

SWbemRefreshableItem

SWbemObjectEx

Scripting API Objects