如何在 Configuration Manager 中从 WIM 文件添加启动映像

可以通过创建 SMS_BootImagePackage 的实例,将 Windows 映像 (WIM) 文件中的启动映像添加到Configuration Manager。 属性 ImagePath 必须设置为通用命名约定 (UNC) WIM 文件的路径。 属性 ImageIndex 是 WIM 文件中所需映像的索引。

如果启动映像需要 Windows 驱动程序,请在 属性中 ReferencedDrivers 指定它们,该属性是 SMS_Driver_Details数组。

注意

更新启动映像时,例如,当Configuration Manager二进制文件或启动映像属性发生更改时,必须通过调用 SMS_BootImagePackageRefreshPkgSource 方法来更新启动映像。

从 WIM 文件添加启动映像

  1. 设置与 SMS 提供程序的连接。 有关详细信息,请参阅 SMS 提供程序基础知识

  2. 创建 SMS_BootImagePackage 实例。

  3. 至少设置 Name、ImagePath 和 ImageIndex 属性。

  4. 提交更改。

示例

以下示例方法从 WIM 文件添加启动映像。

有关调用示例代码的信息,请参阅调用Configuration Manager代码片段

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;  
    }  
}  

示例方法具有以下参数:

参数 类型 说明
connection -管理: WqlConnectionManager
- VBScript: SWbemServices
与 SMS 提供程序的有效连接。
name -管理: String
- VBScript: String
新启动映像包的名称。
description -管理: String
- VBScript: String
启动映像包的说明。
pathToWIM -管理: Integer
- VBScript: Integer
映像的 UNC 路径。

编译代码

C# 示例具有以下编译要求:

命名空间

System

System.Collections.Generic

System.Text

Microsoft。ConfigurationManagement.ManagementProvider

Microsoft。ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

可靠编程

有关错误处理的详细信息,请参阅关于Configuration Manager错误

.NET Framework 安全性

有关保护Configuration Manager应用程序的详细信息,请参阅Configuration Manager基于角色的管理

另请参阅

如何将包分配到分发点
如何将 Windows 驱动程序添加到Configuration Manager启动映像包
如何将包分配到分发点
关于映像管理