Bewerken

Share via


SWbemObjectEx.Refresh_ method

The Refresh_ method of SWbemObjectEx updates the data for objects that have data supplied by a performance provider, such as the Performance Counter Classes. You can obtain updated data more quickly and without a call to SWbemServices.Get_.

For more information about this syntax, see Document Conventions for the Scripting API.

Syntax

SWbemObjectEx.Refresh_( _
  [ ByVal iFlags ], _
  [ ByVal objWbemNamedValueSet ] _
)

Parameters

iFlags [in, optional]

Reserved operation flags which, if specified, must be 0 (zero).

objWbemNamedValueSet [in, optional]

An SWbemNamedValueSet object that sets context for the operation.

Return value

This method does not return a value.

Error codes

After completion of the Refresh_ method, the Err object may contain one of the error codes in the following list.

wbemErrFailed - 2147749889 (0x80041001)

The provider failed internally, even though the operation was valid.

wbemErrNotFound - 2147749890 (0x80041002)

The requested format was not found.

wbemErrInvalidParameter - 2147749896 (0x80041008)

One of the parameters to the call is not correct.

wbemErrRefresherBusy - 2147749975 (0x80041057)

The refresher is busy with another operation.

wbemPartialResults - 2147745808 (0x80040010)

Not all of the objects, enumerators, or nested refreshers were successfully updated. This return is not an error but an indication that the operation was incomplete.

Examples

The following script code example shows how to obtain both raw and cooked performance counters for the system process. The objects are refreshed every two seconds and the properties displayed.

' Get the performance counter instance for the System process
set PerfRaw = GetObject( _
    "winmgmts:win32_perfrawdata_perfproc_process.name='system'")
set PerfCooked = GetObject( _
    "winmgmts:win32_perfformatteddata_perfproc_process.name='system'")

' Display some properties in a loop
for I = 1 to 5
    Wscript.Echo "HandleCount = "& PerfRaw.HandleCount & _
         " Raw ThreadCount = " & PerfRaw.ThreadCount & _
        " Cooked ThreadCount = " & PerfCooked.ThreadCount
    
    Wscript.Sleep 2000
    
' Refresh the objects
    PerfRaw.Refresh_
    PerfCooked.Refresh_
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_SWbemObjectEx
IID
IID_ISWbemObjectEx

See also

SWbemObjectEx

Monitoring Performance Data