You can use WMI from client applications and scripts. It provides an infrastructure that makes it easy to both discover and perform management tasks. In addition, you can add to the set of possible management tasks by creating your own WMI providers.
The following topics are discussed in this section:
The following procedure describes how to obtain data from WMI by writing a script or application.
To obtain data from WMI by writing a script or application
- Decide which language to use. For more information about scripting, see
Creating a WMI Script.
For more information about C++, see Creating a WMI Application Using C++. For using more information about C# or WMI .NET, see WMI .NET Overview.
You can view or manipulate WMI data in many languages. The following table lists the topics that describe how to use the scripting and application languages to obtain data.
Application language Topic Scripts written in Microsoft ActiveX script hosting, including Visual Basic Scripting Edition (VBScript) and Perl Scripting API for WMI.
Start with Creating a WMI Script.
WMI PowerShell Cmdlets, such as Get-WmiObject.
Visual Basic applications Scripting API for WMI. Active Server Pages Scripting API for WMI.
Start with Creating Active Server Pages for WMI.
C++ applications COM API for WMI. .NET Framework applications written in C#, Visual Basic .NET, or J# Classes in the Microsoft.Management.Infrastructure namespace. (The System.Management namespace is no longer supported). For more information, see WMI .NET Overview.
- Ensure that your connections to remote computers work.
For more information, see Connecting to WMI on a Remote Computer.
- Connecting to WMI on remote computers requires the correct security settings, as explained in Maintaining WMI Security. The following table lists the topics that describe how to configure security settings with the scripting and application languages.
Language Topic Scripts in any language, Visual Basic applications Setting the Default Process Security Level Using VBScript Active Server Pages Configuring IIS 5 and Later for WMI ASP Scripting C++ Setting the Default Process Security Level Using C++ and Setting the Security on IWbemServices and Other Proxies
- After connecting to WMI, you can obtain data through queries and enumerations.
- Registry data is available through WMI and you can create new keys and values or modify existing ones.
For more information, see Modifying the System Registry.
- You can subscribe to event notifications through WMI, either temporarily between system reboots or permanently.
- Performance counter data for a system is available through WMI.
The system performance library counters are converted to WMI classes. For more information, see Monitoring Performance Data.
- WMI Tasks for Scripts and Applications describes how to do many administrative tasks with WMI.
The following procedure describes how to supply data to WMI by writing a provider.
To supply data to WMI by writing a provider
- Decide on the type of provider to write.
You cannot write a WMI provider in VBScript. However, you can take several other approaches to writing a WMI COM provider:
- Using the WMI ATL Wizard in Visual Studio.
- Using COM directly in any integrated development environment.
This approach creates an unmanaged COM provider.
- Using WMI in the .NET Framework to create a managed code provider.
This approach creates a managed code provider. Managed code providers can be written in any .NET Framework language, are simpler to write than WMI COM providers, and can obtain data from the WMI CIM-based classes such as Win32 Classes. However, the .NET Framework WMI provider has some limitations. For more information, see Managing Applications Using WMI.
- Using the provider framework classes is not recommended.
The provider framework has been superseded by the WMI ATL wizards, using COM directly, or .NET Framework providers. Creating a WMI COM provider with the provider framework classes is no longer recommended. The following table lists the topics that describe how to use COM or .NET Framework providers.
Provider Topic COM provider in the same process as WMI Providing Data to WMI COM decoupled provider Incorporating a Provider in an Application .NET Framework provider in C# or Visual Basic.NET Managing Applications Using WMI
The following topics provide information about using WMI to monitor and control enterprise components.
|WMI Tasks for Scripts and Applications||Describes how to find the correct WMI class and procedures to use in scripts and applications that perform common computer and network administration tasks, such as adding a new printer connection for a remote computer or finding all the installed hotfixes on a computer.|
|Creating a WMI Application or Script||Any scripting language, such as VBScript or Perl, that works with ActiveX objects can access WMI data. Applications can access WMI in C++, using the COM API for WMI or in Visual Basic, using the Wbemdisp.tlb type library and the Scripting API for WMI.|
|Connecting to WMI on a Remote Computer||Describes how scripts, applications, and providers can establish connections to WMI on remote computers to obtain data or control hardware and software.|
|Connecting to WMI on a Remote Computer by Using Windows PowerShell||Describes how to use Windows PowerShell to establish connections to WMI on remote computers to obtain data or to control hardware and software.|
|Monitoring Events||Describes how to get event notifications by creating temporary or permanent WMI event consumers.|
|Providing Data to WMI||WMI supplies dynamic management data to client scripts and applications by obtaining it from providers.|
|Getting and Providing Data on a 64-bit Computer||Describes how to access nondefault providers and considerations for provider writers on 64-bit systems.|