Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

WMI .NET Scenarios 

.NET Framework 2.0

The WMI .NET classes enable you to automate administrative tasks. The scenarios in this topic describe the most common tasks you can complete using WMI in .NET Framework.

If you are a new user of both WMI and .NET Framework, start with Getting Started Accessing WMI Data.

If you are experienced with WMI or .NET Framework, you may need information on topics such as accessing data on remote computers or making asynchronous calls. For more information, see Advanced Programming Topics in WMI .NET.

Scenario 1: Receiving WMI Data

See code at How To: Retrieve Information About Managed Objects by Queries.

You can create a client application that requests data from WMI classes. The WMI classes supply information about computer system components such as the version of an operating system, the free space available on a hard drive, the IP address of a computer, or a variety of other data about a computer system. Win32 classes, for example Win32_LogicalDisk and Win32_OperatingSystem, are preinstalled WMI classes that provide the most commonly queried for information. In your application, you query for the desired class properties to receive the data. You use classes in the System.Management namespace to execute the query. For more information on querying for data, see WMI Queries. For information on Win32 classes, see "Win32 Classes" in the Windows Management Instrumentation documentation in the MSDN Library at http://msdn.microsoft.com/library.

Scenario 2: Executing a Method from a WMI Class

See code at How To: Execute a Method.

You can create a client application that executes a method from a WMI class. By executing WMI class methods, you control the behavior of different computer components. For example, you can execute the Create method of the WMI class Win32_Process to start a process, or you can execute the Reboot method of the Win32_OperatingSystem class to reboot a computer. You use classes in the System.Management namespace to execute WMI class methods. For more information on these Win32 classes, see "Win32 Classes" in the Windows Management Instrumentation documentation in the MSDN Library at http://msdn.microsoft.com/library.

Scenario 3: Receiving an Event from WMI

See code at How To: Receive an Event.

You can create a client application that receives events raised by WMI by specifying which type of event to receive. For more information, see WMI Management Events. For example, you can receive an event every time a process is started or stopped, or when the registry on a computer is changed. You use classes in the System.Management namespace to receive an event.

Scenario 4: Accessing a Remote Computer

See code at How To: Connect to a Remote Computer.

You can create a client application that connects to a remote computer, and then either queries for WMI data, executes a method, or receives an event on the remote computer. You use classes in the System.Management namespace to connect to the remote computer. For example, you can connect to a remote computer and check how much free disk space is available on the remote computer's hard drive, reboot the remote computer, or receive an event notification every time the registry is changed on the remote computer.

Scenario 5: Creating a Data or Event Provider

See code at How To: Provide Management Data and Providing Management Events.

You can create an instrumented application, a WMI data or event provider, using the classes in the System.Management.Instrumentation namespace. After creating a data or event provider for an application, other applications can discover the application that has the provider, monitor the application properties you define in your data provider, and configure objects using WMI to get the data you are providing. You allow other people and applications to query for data about your application by using WMI. Be sure to read Limitations of WMI in .NET Framework if you plan to instrument an application.

If you have never created an instrumented application or an original WMI provider, start with Providing Management Information by Instrumenting Applications.

See Also

Other Resources

WMI .NET Overview

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.