One utility for generating code that can be used to work with WMI objects is a free tool from Microsoft, called the
The program is a self-contained executable; no installation is needed. When you run it, it presents you with four tabs:
- Query for Data from a WMI Class;
- Execute a Method;
- Receive an Event; and
- Browse the Namespaces on this Computer.
In each tab there's a dropdown that presents a list of all available namespaces and classes for that namespace; there are also drop-downs or selectors for other entities available with each type of item.
For instance, the Method tab contains a list of methods, as well as parameters. If you're querying for data from a WMI class, you can select the properties, then search for any values available for that property. The Receive an Event tab even has a hotlink directly to the online MSDN library that lets you look up the documentation available for the selected event class.
Once you've selected all the details of the WMI class, the code generated to use that class appears in a right-hand pane. If you want to change the language of the code, select one from the Code Language menu; the program supports C#, VB.NET and classic VBScript. The resulting code can also be automatically opened in Notepad or sent directly to a command line to be executed. Finally, the WMI classes don't have to be pulled exclusively from the current computer; any computer that's accessible via RPC can be polled for WMI objects.
Serdar Yegulalp is editor of the Windows Power Users Newsletter. Check it out for the latest advice and musings on the world of Windows network administrators. He is also author of the book Windows Server Undocumented Solutions.
More information from SearchWinSystems.com
- Tip: Microsoft utility helps admins diagnose WMI services
- Topics: Windows Management Instrumentation
- RSS: Sign up for our RSS feed to receive expert advice every day.
This was first published in May 2006