다음을 통해 공유


How to Delete a Driver Package 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 delete an operating system deployment driver package, in Microsoft System Center Configuration Manager 2007, by deleting its SMS_DriverPackage object.

Note

Windows drivers that are referenced by the driver package are not deleted.

To delete a driver package

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

  2. Get the SMS_DriverPackage object for the driver that you want to delete.

  3. Delete the SMS_DriverPackage object.

Example

The following example method deletes a driver package identified by its package identifier.

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

Sub DeleteDriverPackage(connection,packageID)
    
        ' Get the driver.
        Set driverPackage = connection.Get("SMS_DriverPackage.PackageID='" & packageID & "'")
        
        ' Delete the driver package.
        driverPackage.Delete_

End Sub
public void DeleteDriverPackage(
    WqlConnectionManager connection, 
    string packageId)
{
    try
    {
        // Get the driver package.
        IResultObject driverPackage = connection.GetInstance("SMS_DriverPackage.packageId='" + packageId + "'");

        // Delete the driver package.
        driverPackage.Delete();
    }
    catch (SmsException e)
    {
        Console.WriteLine("Failed to delete driver package: " + 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.

packageID

  • Managed: String

  • VBScript: String

  • The driver package identifier available in SMS_DriverDriverPackage.PackageID.

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.