Troubleshooting WMI Client Applications

WMI contains a set of classes for troubleshooting client applications that use WMI providers. The troubleshooting event classes are coupled to WMI event classes, such that you can track your application execution using a log of captured troubleshooting events.

The following list contains examples of troubleshooting event classes:

The following procedure shows how to troubleshoot application execution.

To set up WMI troubleshooting

  1. Create and compile a MOF file to use the WMI logging event consumer.
  2. Run your client application.
  3. View the troubleshooting log file for all provider operation and failure events, and analyze the log to diagnose the client problems you are encountering.

Another troubleshooting approach is to view the list of providers currently in the computer cache, by enumerating MSFT_Providers in the root\cimv2 namespace. There are methods in this class that enable you to load and unload providers for debugging or setup purposes.

The following code example uses the WMI logging event consumer to capture all events of the parent event class, thus capturing all provider operation events.

#pragma autorecover
#pragma namespace("\\\\.\\root\\subscription")

instance of __EventFilter as $Filter
{
  Name = "ProviderOperationEvents" ;
  EventNamespace = "root\\cimv2" ;
  Query = "SELECT * FROM MSFT_WmiProvider_OperationEvent" ;
  QueryLanguage = "WQL" ;
} ;

Instance of LogFileEventConsumer as $Consumer
{
  Name = "ProviderOperationEvents" ;
  FileName = "C:\\test.txt" ;
  Text = "Operation - %__TEXT%" ;
} ;

instance of __FilterToConsumerBinding
{
  Filter = $Filter ;
  Consumer = $Consumer ;
  MaintainSecurityContext = TRUE ;
} ;

When error messages indicate provider load failure, use MSFT_WmiProvider_LoadOperationFailureEvent to identify which provider caused the fault.

WMI Troubleshooting

WMI Troubleshooting Classes