Configuring WMI Settings

Microsoft® Windows® 2000 Scripting Guide

The default WMI settings are adequate for most computers and most purposes. Under special circumstances, however, you might want to modify the WMI settings on a computer or a group of computers.

For example, a developer might want to configure WMI to log all errors for the purpose of collecting information that could help in debugging applications that use WMI. A system administrator might want to change the default namespace on the company's DNS servers from root\cimv2 to root\MicrosoftDNS. Using a script to change settings such as these is much faster than visiting each computer and manually reconfiguring the WMI service.

You can use the Win32_WMISetting class to reconfigure many of the WMI properties on a computer. Several of the configurable WMI settings are shown in Table 8.13.

Table 8.13 Configurable WMI Settings in the Win32_WMISetting Class

Property

Description

ASPScriptDefaultNamespace

Default script namespace. The default is root\cimv2. You must specify the entire namespace path, including root.

BackupInterval

Length of time that will elapse between backups of the WMI database. The default is 30 minutes.

EnableEvents

Boolean value indicating whether the WMI event subsystem is enabled. By default, EnableEvents is set to True.

HighThresholdOnClientObjects

Maximum rate at which provider-created objects can be delivered to clients. The default value is 20,000,000 objects per second.

HighThresholdOnEvents

Maximum rate at which events are to be delivered to clients. The default value is 2,000,000 event objects per second.

LoggingDirectory

Directory path to the WMI system log files. The default is systemroot\WBEM\Logs.

LoggingLevel

Indicates whether event logging is enabled and the verbosity level of logging used. By default, logging is disabled (set to 0). Values include:

0 - No logging

1 - Error logging

2 - Verbose error logging

LowThresholdOnClientObjects

Rate at which WMI starts to slow the creation of new objects created for clients. The default value is 10,000,000 objects per second.

LowThresholdOnEvents

Rate at which WMI starts to slow the delivery of new events. The default value is 1,000,000 event objects per second.

MaxLogFileSize

Maximum size of the log files produced by the WMI service. The default value is 65536 KB.

MaxWaitOnClientObjects

Amount of time a newly created object waits to be used by the client before it is discarded and an error value is returned. The default value is 60,000 milliseconds (60 seconds).

MaxWaitOnEvents

Amount of time for which an event sent to a client is queued before being discarded. The default value is 2,000 milliseconds (2 seconds).

Scripting Steps

Listing 8.11 contains a script that configures WMI settings on a computer. To carry out this task the script must perform the following steps:

  1. Create a variable to specify the computer name.

  2. Use a GetObject call to connect to the WMI namespace root\cimv2 and set the impersonation level to "impersonate."

  3. Use a GetObject call to connect to the Win32_WMISetting class.

  4. Set the BackupInterval property to 60 minutes.

  5. Set the LoggingLevel to 2 (verbose).

  6. Use the Put_ method to apply the changes.

Listing 8.11 Configuring WMI Settings

  
1
2
3
4
5
6
7
8
9
10
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colWMISettings = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_WMISetting")
For Each objWMISetting in colWMISettings
 objWMISetting.BackupInterval = 60
 objWMISetting.LoggingLevel = 2
 objWMISetting.Put_
Next