Problem solve Get help with specific problems with your technologies, process and projects.

CompClasses.vbs: A custom WMI analyzer/MOF compiler

This tip offers a method for isolating SMS 2003 custom hardware inventory reporting classes and custom data classes.

Today's script provides administrators with a method for isolating System Management Server (SMS) 2003 custom hardware inventory reporting classes and custom data classes. If you subscribe to the notion of isolating the two classes, then you should keep custom reporting classes in the SMS_Def.mof along with the original SMS 2003 setup configuration. Remove all custom data classes from the SMS_Def.mof; they can be managed with a script. See more about this concept in my other article, SMS 2003 hardware customization: A better way. This approach supports using two files plus one MOF file for each custom data class that is created.

  1. SMS_Def.mof -- the file responsible for filtering out unnecessary hardware information and allowing what is required. A change to this file affects the data that is gathered on the client and viewed in the SMS console or in SMS Web reports. To gather data from a client, the Windows Management Instrumentation (WMI) class referenced must already exist, otherwise you have to create it.

  2. Custom MOF files -- one for each WMI data class that must be created.

  3. CompClasses.vbs -- a VBS script that checks for all custom WMI classes for Saudi Aramco and creates the ones that are missing. The program has intelligent error-checking built in. It includes a local log file and the creation of software delivery status MIF (management information format) files to offer custom installation status messages within the SMS console and with SMS Web Reports.

Working with Managed Object Formats
Basically, you will need to cut and paste all of the custom data classes from your SMS_Def.mof into individual MOFs (only for the custom data classes). The new MOFs must have the same file name as the custom class that is being created, including case sensitivity. Place the new MOFs into the same folder as CompClasses.vbs. Generally, custom classes are added to the end of the SMS_Def.mof so start looking there. You can find custom data classes easily by looking for lines that are similar to the following example:

// Extended AddRemovePrograms Data Class #pragma namespace("\\\\. \\root\\CIMV2")
#pragma deleteclass("Win32Reg_ExtAddRemovePrograms",NOFAIL)
[dynamic, provider("RegProv"),
ClassContext("local\HKEY_LOCAL_MACHINE\ \Software\ \Microsoft\\Windows\\CurrentVersion\ \Uninstall")]
class Win32Reg_ExtAddRemovePrograms

In this case, you would cut from the beginning of this section from the SMS_Def.mof and paste it into the new .mof file. Do this for each custom data class. Leave behind all the custom reporting classes. They begin in a similar manner as the following lines:

// Extended AddRemovePrograms Reporting Class #pragma namespace("\\\\. \\root\ \cimv2\ \SMS")
#pragma deleteclass("Win32Reg_ExtAddRemovePrograms",NOFAIL)
[SMS_Report(TRUE), SMS_Group_Name("Add Remove Programs"),
class Win32Reg_ExtAddRemovePrograms : SMS_Class_Template

The foundation script for CompClasses.vbs came from Robert Mahle. His script queried WMI, compiled a custom data class, used a log file and ran hardware inventory. I decided to create a new process at my organization to more safely and efficiently customize hardware inventory. To support the new process, I added some additional functionality to the script, such as first checking the connection to WMI, looping through a list of custom data classes from an input file, creating a software inventory status MIF and adding more error checking.

This script does the following:

  1. Creates a log file in %win%\ms\smswork\compclasses.log.

  2. Checks for ismifcom.dll. If it's missing, the script copies it to the Windows folder and then registers it.

  3. Creates a custom installation status MIF with value of Failed. This is changed to Success at the end of the script.

  4. Tests the connection to WMI. The script tries to read the root/cimv2/Win32_WMISetting class as a test.

  5. Reads the input file for the first custom class in the list. The file classes.txt contains these classes.

  6. Queries WMI for the class.

  7. If the class is found, it logs the action and skips to the next class in the list.

  8. If the class is missing, the script runs MOFComp to compile the proper MOF, which results in the creation of only the missing class.

  9. If MOFComp was run, it re-queries WMI for the missing class.

  10. If the missing class was not created after running MOFComp, the script creates a Failure status MIF and a failure log entry, and then it exits.

  11. If successful at creating the class, it goes to the next class in the list.

  12. If MOFComp was run and when done reading the input file, hardware inventory is cycled.

Customizing CompClasses.vbs
The script accesses the files from the folder where it is called, looking for the custom MOF files, Classes.txt and Ismifcom.dll. This allows the source folder to be imported into an SMS package and delivered to a client. For best results, configure the advertisement to have the client download the files from a distribution point.

Edit every instance of the following line adding a new MIF file name, package name and package version:
objMif.Create " ", " ", " ", " Note: This information must match the Name: and Version: fields in the General tab of the SMS package that you will use to distribute the script. The MIF file name must match the Reporting tab on the same package. Also, be sure all the fields on the Reporting tab match with those on the General tab.

Editing Classes.txt
This file simply lists the custom classes exactly as they appear in Wbemtest, including case sensitivity. Class names should appear in a single column at the left of the file.

Creating custom classes on standalone systems
A delay occurs between the time when a new system comes on the network and the time when custom data is sent to the management point (MP). Several processes must occur: The client may need to be installed, it must download a policy that contains the SMS_Def.mof customizations, and then it must initiate hardware inventory. To more quickly gather data from newly imaged systems, run the script manually immediately after the image process completes but before the Advanced Client begins to communicate with the management point for the first time. After the client is able to download the first set of policies from the MP, force a hardware inventory.

Here is the download link for the script. It includes three files: Complclasses.vbs, Classes.txt and a custom MOF. You must download Ismifcom.dll from the SMS 2003 software development kit (SDK): Good luck!

Dana Daugherty is a systems analyst with Saudi Aramco, the largest oil producing company in the world. He is a member of the Windows System Management group and is responsible for providing solutions to other IT groups for managing Windows operating systems. Daugherty can be reached at

Dig Deeper on Windows systems and network management

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.