Printer Friendly Version      Send     
Click to Rate and Give Feedback
Related Articles
This Tip will explain how to send email from Exchange ...

Read more!

Make a new tip by beating yourself in the head with a keyboard ...

Read more!

Waka wakka wakka! ...

Read more!

You know what ...

Read more!

Popular Articles

See how this free utility can help you determine whether problems you are experiencing while running Windows are caused by faulty memory.

Lance Whitney

TechNet Magazine September 2008

...

Read more!

User Account Control, or UAC, is one of the most misunderstood new features in Windows Vista. But its goal—to enable users to run with standard user rights—can solve many security issues. Get an inside look at the problems UAC is designed to address and see exactly how this new feature works.

Mark Russinovich

TechNet Magazine June 2007

...

Read more!

The introduction of Hyper-V makes virtualization an even more compelling solution for IT environments. Get an overview of today’s virtualization market and see how Hyper-V improves the manageability, reliability, and security of virtualization

Rajiv Arunkundram

TechNet Magazine October 2008

...

Read more!

Far too often, people who are not trained database administrators somehow end up responsible for a database. They lack the proper training and knowledge to maintain their database, and problems begin to develop. Here’s a primer for all those involuntary DBAs who need a crash course in database maintenance best practices.

Paul S. Randal

TechNet Magazine August 2008

...

Read more!

The new version of SQL Server offers a host of new features and enhancements that promise to improve performance, increase security, and make life better for database administrators. Here’s an overview of the key changes and what you can expect from SQL Server 2008.

Randy Dyess

TechNet Magazine April 2008

...

Read more!

Our Blog
In the November 2008 installment of our Windows PowerShell column (which is available online), Don Jones demonstrates how to create a tool that will inventory the operating system build number (this is one of the best ways to determine the OS version) and service pack version number from a list of computers.  ...

Read more!

In this month’s TechNet Magazine, you’ll find the second of a series of Field Notes columns written by Romi Mahajan, Chief Marketing Officer of Ascentium Corporation. As an early innovator in the field of electronic ...

Read more!

Have you ever wondered why you sometimes get a message that says Windows can't replace a file that is currently in use? In the November 2008 issue of TechNet Magazine, Raymond Chen looks at the underlying reason for this and explains why it would be more accurate to say Windows can but has chosen not to ...

Read more!

The complexity of systems today makes troubleshooting more difficult than ever. It’s harder to keep track of what has changed, when, and how that relates to everything else. If something goes wrong, chances are good that users will have a hard time figuring out what has changed on their computers, whether due to updates, new software, ...

Read more!

"For developers, one difficult problem in SQL Server is tracking what data has changed in a database. An even greater challenge is architecting a simple solution that doesn’t heavily impact workload performance and isn't difficult to create, implement, and manage. So why go to all the trouble to track changes? Is tracking changes really worth all this effort? Two commonly cited examples are to support updates to a data warehouse and to support the synchronization of heterogeneous, occasionally connected systems." ...

Read more!

Utility Spotlight WMI Code Creator
Chris Scoville

Download the code for this article: WMI Code Creator (122KB)

As a systems administrator you’re surely no stranger to Windows®Management Instrumentation (WMI), which gives you access to a wealth of management information and allows you to automate administrative tasks. To take full advantage of WMI you have to write queries to extract the information you need. And if you don’t have the ready-made queries already floating around in your head, you just might want to take the WMI Code Creator for a spin. It’s a recently released tool that generates custom code to use WMI so you can get the most from the myriad of computer management options that WMI has to offer.
The WMI Code Creator can generate code in VBScript, C#, and Visual Basic® .NET; you can run the code directly from the tool. You can generate code to query for management information, execute a management task, or receive event notifications.
For example, suppose you want to get a list of all the services running on a computer. You can use the WMI Code Creator to query for this information by selecting the WMI class you want to query (Win32_Service) and the properties that contain the information you are interested in accessing. And you can do more than just execute queries. Let’s say you want to start a service that isn’t running. You can use the WMI Code Creator to generate a script to do that too. All the code is generated for you based on a few selections you make. Plus, the tool contains step-by-step help to teach you how to use it to get the information you want.
The WMI Code Creator generates code that you can point at remote computers as well. You can query for the same kind of data you can get on local computers, receive event notifications, and even execute tasks remotely. All you need to do is enter the domain and name of the remote computer, and the code is generated automatically.
Figure 1 shows an example of event notification code generated by the WMI Code Creator. Note that you can set the frequency at which WMI should poll for the specified events, and you can edit or execute the code as well.
Figure 1 WMI Code Creator Generating Event Notification Code 
If you aren’t familiar with all of the WMI classes and their uses, the WMI Code Creator lets you browse through the available WMI classes on your computer, and displays descriptions of these classes, their properties, and methods. The WMI Code Creator also lets you quickly access the documentation for a WMI class by linking you to the specific class page in the MSDN® WMI documentation online.
The WMI Code Creator download also includes the source code, which serves as a really handy tool for learning how to use the System.Management classes in the Microsoft® .NET Framework to access WMI. The tool was built using WMI, and the source code provides many examples for how to use WMI to add functionality to an application.
Use the tool to open up a world of WMI functionality and all the computer management possibilities it provides. It will save you time writing administrative scripts and code, and provide you with excellent examples and solutions. You can download the utility from WMI Code Creator.

Chris Scoville is a programming writer in the Windows Server Developer Documentation group at Microsoft. He writes documentation and code examples for management technologies. He developed the WMI Code Creator tool.  Chris can be reached at chscovil@microsoft.com
© 2008 Microsoft Corporation and CMP Media, LLC. All rights reserved; reproduction in part or in whole without permission is prohibited.
Page view tracker