In Microsoft System Center Configuration Manager 2007, you add a category to a Windows driver by adding the unique identifier for the category to the SMS_Driver Server WMI Class CategoryInstance_UniqueIDs array property. The array contains one or more string identifiers that match the SMS_CategoryInstance Server WMI Class CategoryInstance_UniqueID property value. There is an instance of SMS_CategoryInstance Server WMI Class object for each category in the system.

The unique identifier for a driver category is prepended with the text "DriverCategories". Other category types have different text.

A category has localization information, and it is from the SMS_CategoryInstance Server WMI Class LocalizedCategoryInstanceName property that the display name of the category is obtained.

To add a category to a Windows driver

  1. Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.

  2. Get the SMS_Driver object for the driver you want to add a category to.

  3. Get the category name identifier from the SMS_CategoryInstance Server WMI Class object that matches the desired category.

  4. Add the category identifier to the SMS_Driver Server WMI Class object CategoryInstance_UniqueIDs array property.

  5. Commit the SMS_Driver Server WMI Class changes.


The following example methods adds a category to a Windows driver. driverID is a valid SMS_Driver Server WMI Class object. For more information, see About Operating System Deployment Driver Management.

For information about calling the sample code, see Calling Configuration Manager Code Snippets.

Visual Basic Script  Copy Code
Sub AddDriverCategory(connection,driver,categoryName)

	Dim categories
	Dim category
	Dim driverCategoryID
	Dim categoryID
	Dim results
	Dim existingCategory
	' Find the category that matches the supplied category name.
	Set results = _
	connection.ExecQuery("SELECT * From SMS_CategoryInstance WHERE LocalizedCategoryInstanceName = '" _
	+ categoryName+ "'")
	' If the category was found, add it to the driver.
	For Each category in results

		If IsNull(driver.CategoryInstance_UniqueIDs) or UBound (driver.CategoryInstance_UniqueIDs) = -1 Then
			' It is empty. Add the category.
			driver.CategoryInstance_UniqueIDs =  Array(category.CategoryInstance_UniqueID)
			' Determine if the category is already applied to the driver.
			For each existingCategory in driver.CategoryInstance_UniqueIDs 
				if existingCategory = category.CategoryInstance_UniqueID Then
					WScript.Echo "Already added"
					Exit Sub
				End If
			' Add the category.
			categories = driver.CategoryInstance_UniqueIDs
			Redim Preserve categories (UBound (driver.CategoryInstance_UniqueIDs)+1)
			categories (Ubound (categories)) =  category.CategoryInstance_UniqueID 
			driver.CategoryInstance_UniqueIDs = categories
		End If

End Sub
C#  Copy Code
public void AddDriverCategory(
	WqlConnectionManager connection,
	IResultObject driver,
	string categoryName)
		// Get the category.
		IResultObject results = connection.QueryProcessor.ExecuteQuery(
		"SELECT * From SMS_CategoryInstance WHERE LocalizedCategoryInstanceName = '" + categoryName + "'");

	 ArrayList driverCategories = new ArrayList(driver["CategoryInstance_UniqueIDs"].StringArrayValue);//;driverCategories);

		foreach (IResultObject category in results)
			foreach (string driverCategory in driverCategories)
				// Do nothing if the driver already has the category.
				if (driverCategory == category["CategoryInstance_UniqueID"].StringValue)
					Console.WriteLine("Already exists");

			// Add the category to the action.

		// Update the driver.
		driver["CategoryInstance_UniqueIDs"].StringArrayValue = (string[])driverCategories.ToArray(typeof(string));

	catch (SmsException e)
		Console.WriteLine("Failed to add the category" + e.Message);

The example method has the following parameters:

Parameter Type Description


  • Managed:WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.


  • Managed: IResultObject

  • VBScript: SWbemObject

The Windows driver. It is an instance of SMS_Driver Server WMI Class.


  • Managed: String

  • VBScript: String

The name of an existing category. This matches the SMS_CategoryInstance Server WMI Classe LocalizedCategoryInstanceName property.

Compiling the Code

This C# example requires:










Robust Programming

For more information about error handling, see About Configuration Manager Errors.


For more information about securing Configuration Manager applications, see About Securing Configuration Manager Applications.

See Also

Send comments about this topic to Microsoft.