Querying WMI

One of the main tools of Windows Management Instrumentation (WMI) is the ability to query the WMI repository for class and instance information. For example, you can request that WMI return all the objects representing shut-down events from your desktop system. You can also retrieve class, instance, or schema data. The following table lists the different types of queries you can make.

Invoking a Synchronous Query Describes how to maintain a link with WMI throughout the query process. Synchronous queries are good for small queries or queries to a local system.
Invoking an Asynchronous Query Describes how to set up a separate process to receive queries. Asynchronous queries are more complex and provide a lower level of security, but generally improve system performance.


In addition to querying the WMI repository, you can also use the WMI Query Language (WQL) to route notification events to your application. For more information, see Receiving a WMI Event.

Note  To properly query WMI, you must have a good understanding of WQL. A query that is incorrect, too complex, or inappropriate can cause the query processor to return an error or unexpected results. For a comprehensive guide to WQL, see Querying with WQL.

There are limits to the number of AND and OR keywords that can be used in WQL queries. Large numbers of WQL keywords used in a complex query can cause WMI to return the WBEM_E_QUOTA_VIOLATION error code as an HRESULT value. The limit of WQL keywords depends on how complex the query is.

For more information, see Manipulating Class and Instance Information.



© 2014 Microsoft