Freigeben über


How to Add a Boot Image from a WIM File 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 add a boot image from a Windows Image (WIM) file to Microsoft System Center Configuration Manager 2007 by creating an instance of SMS_BootImagePackage Server WMI Class. The property ImagePath must be set to the Universal Naming Convention (UNC) path to the WIM file. The property ImageIndex is the index to the required image within the WIM file.

If the boot image requires Windows drivers, you specify them in the ReferencedDrivers property, which is an array of SMS_Driver_Details Server WMI Class.

Note

   When the boot image is updated, for example, when a Configuration Manager 2007 binary or boot image property is changed, the boot image must be updated by calling the SMS_BootImagePackage class RefreshPkgSource method.

To add a boot image from a WIM file

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

  2. Create an instance of SMS_BootImagePackage.

  3. Set at least the Name, ImagePath and ImageIndex properties.

  4. Commit the changes.

Example

The following example method adds a boot image from a WIM file.

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

Sub AddBootImagePackage(connection, name, description, pathToWim)

    Dim bootImagePackage 
    
    Set bootImagePackage = connection.Get("SMS_BootImagePackage").SpawnInstance_()
    ' Populate the new package properties.
    bootImagePackage.Name = name
    bootImagePackage.Description = description
    
    bootImagePackage.ImagePath = pathToWim  'UNC path to WIM file.
    bootImagePackage.ImageIndex = 1 ' Index into WIM file for image
    
    bootImagePackage.Put_
 
End Sub
public void AddBootImage(
    WqlConnectionManager connection, 
    string name, 
    string description, 
    string pathToWim)
{
    try
    {
        // Create new boot image package object.
        IResultObject bootImagePackage = connection.CreateInstance("SMS_BootImagePackage");

        // Populate new boot image package properties.
        bootImagePackage["Name"].StringValue = name;
        bootImagePackage["Description"].StringValue = description;
        bootImagePackage["ImagePath"].StringValue = pathToWim; // UNC path required.
        bootImagePackage["ImageIndex"].IntegerValue = 1; // Index into WIM file for image.

        // Save new package and new package properties.
        bootImagePackage.Put();
    }
    catch (SmsException e)
    {
        Console.WriteLine();
        Console.WriteLine("Failed to create package. Error: " + e.Message);
        throw;
    }
}

The sample method has the following parameters:

Parameter

Type

Description

connection

  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.

name

  • Managed: String

  • VBScript: String

Name for the new boot image package.

description

  • Managed: String

  • VBScript: String

Description for the boot image package.

pathToWIM

  • Managed: Integer

  • VBScript: Integer

UNC path to the image.

Compiling the Code

The C# example has the following compilation requirements:

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.

See Also

Concepts

How to Assign a Package to a Distribution Point
How to Add a Windows Driver to a Configuration Manager Boot Image Package
How to Assign a Package to a Distribution Point