Partager via


How to Enable or Disable a Windows Driver in Configuration Manager

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

You enable or disable a Windows driver in the operating system deployment driver catalog, in Microsoft System Center Configuration Manager 2007, by setting the IsEnabled property of the SMS_Driver Server WMI Class object. A driver can be disabled to prevent it from being installed by the Auto Apply Driver action in a task sequence.

To enable or disable 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 enable or disable.

  3. Set the IsEnabled property to true to enable the driver, or to false to disable the driver.

  4. Commit the SMS_Driver object changes.

Example

The following example method enables or disables a driver depending on the value of the enableDriver parameter.

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

Sub EnableDriver(connection,driverID,enableDriver)
    
        ' Get the driver.
        Set driver = connection.Get("SMS_Driver.CI_ID=" & driverID)

        ' Set the flag.
        driver.IsEnabled=enableDriver
        
        ' Commit changes.
        driver.Put_

End Sub
public void EnableDriver(
    WqlConnectionManager connection, 
    int driverId, 
    bool enableDriver)
{
    try
    {
        // Get the driver.
        IResultObject driver = connection.GetInstance("SMS_Driver.CI_ID=" + driverId);

        // Set the flag.
        driver["IsEnabled"].BooleanValue = enableDriver;

        // Commit the changes.
        driver.Put();
    }
    catch (SmsException e)
    {
        Console.WriteLine("Failed: " + e.Message);
        throw;
    }
}

The example method has the following parameters:

Parameter Type Description

Connection

  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.

driverID

  • Managed: Integer

  • VBScript: Integer

The Windows driver identifier available in SMS_Driver.CI_ID.

enableDriver

  • Managed: String

  • VBScript: String

Flag to enable or disable the driver.

true - The driver is enabled.

false - The driver is disabled.

Compiling the Code

This C# example requires:

Namespaces

System

System.Collections.Generic

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

Robust Programming

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

Security

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