Introduction to WQL: SQL for WMI
(Page 1 of 4 )
According to Microsoft’s MSDN, the WMI Query Language (WQL) is a subset of the American National Standards Institute Structured Query Language (ANSI SQL) with minor semantic changes. Queries built using WQL are used to control the WMI Service.
Those familiar with SQL will find making the adjustment to WQL very simple. Those new to it will probably find it a bit tough to learn in the beginning. Once you start getting a handle on the query logic and the command structure, it should become dramatically easier.
It’s important to have some understanding of how WMI works. It’s also difficult to give a clear-cut definition. Try to think of WMI as a repository of properties and methods related to the system environment that you will access like a database.
While WMI’s intended purpose was to provide access to system hardware, it has since been expanded to cover network protocols, the Windows registry, and much more. And it can be further expanded by adding additional Providers.
Providers are groups of WMI Classes that are designed to perform specific or similar tasks. They consist of the necessary code (methods involved in retrieving and setting data) and a schema (a document describing the type of information being returned).
Think of Providers as individual databases within your WMI repository. While you’ll learn an exclusion later (Associators), for the most part, you cannot move between Providers. You must make a unique query for each one you need. (In WSH, this means instantiating separate objects for each of them).
Individual groups of related methods and properties are contained within WMI Classes. Think of Classes as the tables within your imaginary database. They contain groups of properties and methods that can be polled and manipulated like data fields.
The topics in this article are very broad. I don’t have any way to cover them thoroughly. My aim is to provide you with a starting place to work from. There have been a number of excellent books written on the subjects of WMI and SQL should you want more information.
There are three types of WQL queries supported by WMI. We’re going to take a look at each of them now. I’m also going to show you an example of each. Don’t worry if you don’t fully understand the syntax.
Next: Data Queries >>
More Windows Scripting Articles
More By Nilpo/Developer Shed Staff Writer