Scripting API Constants

WMI uses several types of constants in the iflags parameter of method calls in the Scripting API for WMI.

Visual Basic applications can include the type library for the scripting API, Wbemdisp.tlb. Scripts are unable to access constants in the type library unless they use the <REFERENCE> or <OBJECT> tags from the Windows Script Host (WSH) XML file format as described in Using the WMI Scripting Type Library. Otherwise, a script must use the value of the constant.



Define the security authentication levels.


Define how a write operation to a class or an instance is carried out.


Define the valid CIM types of a property value.


Define the settings for object comparison and are used by SWbemObject.CompareTo_.


Defines a security flag that is used as a parameter in calls to the SWbemLocator.ConnectServer method when a connection to WMI on a remote machine is failing.


Define the errors that may be returned by Scripting API for WMI calls.


Defines constants that are used by SWbemServices.ExecQuery, SWbemServices.ExecQueryAsync, SWbemServices.SubclassesOf, and SWbemServices.InstancesOf.


Define the security impersonation levels. These constants are used with SWbemSecurity.


Define the valid object text formats to be used by SWbemObjectEx.GetText_.


Define privileges. These constants are used with SWbemSecurity to grant the privileges required for some operations.


Define the depth of enumeration or query, which determines how many objects are returned by a call.


Defines the content of generated object text and is used by SWbemObject.GetObjectText_.


Defines the time-out constants. This constant is used by SWbemEventSource.NextEvent.

Combining Flags

You can combine flags to affect more than one aspect of the API call.

For example, to create a semisynchronous call, the iFlags parameter in an SWbemServices.ExecQuery_ call must contain two flags: WbemFlagReturnImmediately and WbemFlagForwardOnly. The value of WbemFlagReturnImmediately is 16 and the value of WbemFlagForwardOnly is 32. Because the constants cannot be accessed by name, the values of these flags are combined, producing an iFlags value of 48.

The following script example shows the call.

On Error Resume Next
For Each obj in GetObject("WinMgmts:").ExecQuery _
("SELECT * FROM Win32_NTLogEvent WHERE _ LogFile='Application'",,48)
    count  = count + 1

Not all flags can be combined since many are mutually exclusive and may produce unpredictable results.

Scripting API for WMI