使用單一 .WIM 檔案擷取和套用 Windows 映像。

擷取 Windows 映射 (.WIM) 檔案,並用它來將 Windows 部署到新的裝置。

您可以從 Windows 發行 ISO 的 install.wim 檔案開始,或將執行中的 Windows 映像通用化並擷取到 .WIM 檔案中。

WIM 檔案只會擷取單一分割區。 通常,您可以擷取 Windows 分區,然後使用該映像中的檔案來設置驅動器上的其他分區。 如果您已建立自定義分割區組態,請參閱 擷取和套用 Windows、系統和復原分割區

此圖顯示配備空硬碟的新電腦,加上單一 .wim 映像檔,展開為多個已設定的分割區

擷取映像

  1. 如果您已開機進入 Windows,請將映像一般化,使其可以部署到其他裝置。 如需詳細資訊,請參閱 Sysprep (一般化) Windows 安裝

  2. 使用 Windows PE 開機裝置。

  3. 自選 將映像優化,以減少套用映射之後裝置開機所需的時間。 優化映像對於您在建置要部署到許多機器的映像時特別有幫助,例如在製造存貨的情境中。

    DISM /image:C:\ /optimize-image /boot
    
  4. 擷取 Windows 磁碟分區。 例如:

    Dism /Capture-Image /ImageFile:"D:\Images\Fabrikam.wim" /CaptureDir:C:\ /Name:Fabrikam
    

    其中 D:是 USB 快閃磁碟驅動器或其他檔案儲存位置。

套用圖像

  1. 使用 Windows PE 開機裝置。

  2. 抹除硬碟,並使用 腳本設定新的硬碟磁碟分區。 針對舊版舊版 BIOS 裝置使用 CreatePartitions-UEFI.txt (或 CreatePartitions-BIOS.txt )。

    diskpart /s CreatePartitions-UEFI.txt
    
  3. 使用 腳本套用映像。

    D:\ApplyImage.bat D:\Images\Fabrikam.wim
    

範例指令碼

以下是將映像檔套用到已經使用步驟 2 的其中一個硬碟分割腳本分割過的磁碟的簡單範例腳本。

Note

若要使用 Windows UEFI 2023 CA 設定開機,您可以在下列範例腳本中使用 /bootex 選項搭配 bcdboot 命令

rem == ApplyImage.bat ==

rem == These commands deploy a specified Windows
rem    image file to the Windows partition, and configure
rem    the system partition.

rem    Usage:   ApplyImage WimFileName 
rem    Example: ApplyImage E:\Images\ThinImage.wim ==

rem == Set high-performance power scheme to speed deployment ==
call powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c

rem == Apply the image to the Windows partition ==
dism /Apply-Image /ImageFile:%1 /Index:1 /ApplyDir:W:\

rem == Copy boot files to the System partition ==
rem == Note: specify /bootex parameter to use Windows UEFI 2023 CA
W:\Windows\System32\bcdboot W:\Windows /s S:

:rem == Copy the Windows RE image to the
:rem    Windows RE Tools partition ==
md R:\Recovery\WindowsRE
xcopy /h W:\Windows\System32\Recovery\Winre.wim R:\Recovery\WindowsRE\

:rem == Register the location of the recovery tools ==
W:\Windows\System32\Reagentc /Setreimage /Path R:\Recovery\WindowsRE /Target W:\Windows

:rem == Verify the configuration status of the images. ==
W:\Windows\System32\Reagentc /Info /Target W:\Windows

使用 Full Flash Update (FFU) 部署 Windows

擷取並套用 Windows、系統及復原分割區

設定 UEFI/GPT 型硬碟磁碟分割

設定 BIOS/MBR-Based 硬碟磁碟分區

BCDboot Command-Line 選項

REAgentC 命令列選項