Querying and Updating the WMI Repository

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

You can use Windows Management Instrumentation (WMI) to view and update a running application's configuration data when you use the Manageable Configuration Source to expose your Enterprise Library configuration. The Manageable Configuration Source reads information from the configuration file, applies any applicable Group Policy overrides, and exposes the configuration information to applications as a series of configuration class instances in the same way as the other Enterprise Library configuration sources.

However, the Manageable Configuration Source also exposes the configuration information through the .NET WMI 2.0 API and to the WMI Repository as a set of WMI classes that you can query and view. This allows administrators and users to examine configuration information using standard Windows-based management tools or code.

In addition, administrators and users can update the values of the WMI objects using standard Windows-based management tools or code. These changes update the configuration information exposed to the application by the Manageable Configuration Source, which also raises a ConfigurationChanged event that allows the application to react to the changes and reload the new configuration values.

Figure 1 shows the processes and objects of the Manageable Configuration Source.

Ff647363.65cb23e1-d1f4-4ecd-ae2b-56bd1b2ca464(en-us,PandP.10).png

Figure 1
The processes for the Manageable Configuration Source

Note

You must have the relevant Windows permissions to update WMI objects. In addition, as changes pass back to the Manageable Configuration Source, it reapplies any relevant Group Policy overrides. If the change conflicts with a Group Policy setting, the Manageable Configuration Source will ignore the change and continue to expose the Group Policy-applied value.

Changes you make to the configuration exposed by the WMI objects are exposed by the Manageable Configuration Source and are visible in the application. However, they do not change the contents of the original configuration file. When the application restarts, or if you make changes to the configuration file contents, any updates made through WMI are lost.

The following table lists the ways you can query and update values in the WMI Repository.

Application language

Recommended technique

.NET Framework applications

Use classes in the System.Management namespace.

Scripts written in Microsoft ActiveX script hosting, including Visual Basic Scripting Edition (VBScript), Microsoft JScript, and Perl

Use a scripting API for WMI.

Visual Basic 6.0 applications

Use a scripting API for WMI.

PowerShell scripts.

Use a scripting API for WMI.

Active Server Pages

Upgrade to ASP.NET and use the classes in the System.Management namespace.

C++ applications

Adapt the application to use the .NET Framework. Use C++/CLI along with the classes in the System.Management namespace, or use the COM API for WMI.

This section discusses how to use two utilities to examine the WMI objects created by the manageable configuration source:

  • Windows Management Instrumentation Tester (WBEMTest). This is part of the Windows operating system.
  • WMI CIM Studiofrom the WMI Administrative Tools. This is a collection of tools available for download in the Microsoft Download Center. It also includes the WMI Object Browser, WMI Event Viewer, and theWMI Event Registration Tool.

For information about application management through WMI, see Managing Applications Using WMI.

For details about using scripts and other techniques for accessing WMI, see Creating a WMI Application or Script. WMI can also be accessed using Windows PowerShell. For more details, see Accessing WMI From Windows PowerShell.

The WMI Diagnosis Utility (WMIDiag.vbs) is a VBScript script that helps you ascertain the current state of the WMI service on a computer. The download package includes the utility itself, a ReadMe file that provides more details about the tool, and explains how to use it, along with sample spreadsheets that provide information about the default WMI configuration on different versions of the Microsoft Windows operating system. You can download the WMI Diagnosis Utility from the Microsoft Download Center.

Using the WBEMTest Utility

The Windows Management Instrumentation Tester dialog box (WBEMTest) is a general-purpose tool that you can use to query and update any section of the WMI repository. This includes custom sections such as those for Enterprise Library.

To use the Windows Management Instrumentation Tester

  1. To view the WMI data for Enterprise Library, you must first run an application that uses an Enterprise Library App.config file.
  2. While the application is running, click Start, click Run, type wbemtest, and then click OK.
  3. In the Windows Management Instrumentation Tester dialog box, click Connect.
  4. In the Connect dialog box, type the namespace root\EnterpriseLibrary, and then click Connect.
  5. Click Enum Classes to search for a specific class to view. To view all available classes, leave the Enter superclass name text box empty, select the Recursive radio button, and then click OK.
  6. Double-click an entry in the list of top-level classes that appear in the QueryResult dialog box. This opens the Object editor dialog box, where you can view, edit, or delete the qualifiers, properties, and methods for the class. You can also view the Microsoft Operations Framework (MOF) description of the current object and individual instances.
  7. To navigate to another object in the class hierarchy, click the Derived button to open the Query result dialog box. This automatically shows the result of querying for derived classes.
  8. Double-click a class in the Query result dialog box to show the Object editor dialog box for that class.
  9. Edit the values if required and save the changes to update the configuration exposed to the application through the Manageable Configuration Source.

To query for a specific class in the WBEMTest utility

With the application running, click Start, click Run, type wbemtest, and then click OK.

In the main Windows Management Instrumentation Tester dialog box, click Connect.

In the Connect dialog box, type the namespace root\EnterpriseLibrary, and then click Connect.

In the main Windows Management Instrumentation Tester dialog box, click Query.

In the Query dialog box, enter a query to select the items you require. Here some examples:

  • To get the configuration for an application, type SELECT * FROM ConfigurationSetting WHERE ApplicationName = "myApplication", and then click Apply.
  • To get the configuration for a section of an application, type SELECT * FROM ConfigurationSetting WHERE ApplicationName = "myApplication" AND SectionName = "mySectionName", and then click Apply.
  • To get connection strings for an application, type SELECT * FROM ConnectionStringSetting WHERE ApplicationName = "myApplication", and then click Apply.

Note

It is currently not possible to perform a query for all the implementations of an abstract service.

In the Query result dialog box, double-click an instance to open it in the Object Editor.

Edit the values if required and save the changes to update the configuration exposed to the application through the Manageable Configuration Source.

Note

By default, the WMI/Group Policy provider applies Group Policy settings when it retrieves the configuration information and ignores any changes you make to values that conflict with Group Policy settings.

Using the WMI CIM Studio

The WMI Administrative Tools provide a comprehensive set of tools for monitoring, querying, and working with data exposed by WMI. You can use the WMI CIM Studio tool to view and edit the data exposed by WMI.

To view WMI information using WMI CIM Studio

  1. To view the WMI data for Enterprise Library, you must first run any application that uses an Enterprise Library App.config file.
  2. After you start the application, start WMI CIM Studio from the WMI Tools section of the Start menu. You may have to right-click in the Information Bar in Internet Explorer and then click Allow Blocked Content to allow the ActiveX controls it uses to install and run.
  3. In the Connect to namespace dialog box, type root\EnterpriseLibrary to connect to the Enterprise Library configuration information, and then click OK.
  4. In the WMI CIM Studio Login dialog box that opens next, you can specify logon details for WMI, including impersonation and authentication level. Leave all these settings at their default values, and then click OK.
  5. WMI CIM Studio reads the data from the WMI repository and displays a tree view in the left window. You can select a class here, and the right window displays the properties, methods, and associations for this class.
  6. Select a class for which there are concrete instances available, and then click the Instances button in the toolbar above the list of properties on the right. This shows the list of available instances in the right window. Select one by double-clicking it. The right window displays the properties, methods, and associations of the selected instance.
  7. Edit the values if required and save the changes to update the configuration exposed to the application through the Manageable Configuration Source.

Note

By default, the WMI/Group Policy provider applies Group Policy settings when it retrieves the configuration information and ignores any changes you make to values that conflict with Group Policy settings.