' 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