Поділитися через


Capture and apply a Windows image using a single .WIM file

Capture a Windows image (.WIM) file and use it to deploy Windows to new devices.

You can start with either the install.wim file from a Windows distribution ISO, or you can generalize and capture a running Windows image into a .WIM file.

WIM files only capture a single partition. You can usually capture just the Windows partition, and then use files from that image to set up the rest of the partitions on the drive. If you've created a custom partition configuration, see Capture and Apply Windows, System, and Recovery Partitions.

Diagram showing a new computer with an empty hard drive, plus a single .wim image file, expands to become multiple configured partitions

Capture the image

  1. If you've booted into Windows, generalize the image so that it can be deployed to other devices. For more information, see Sysprep (Generalize) a Windows installation.

  2. Boot the device using Windows PE.

  3. Optional Optimize the image to reduce the time it takes your device to boot after you apply the image. Optimizing an image especially helps when you're building an image that you'll be deploying to many machines, like in a build-to-stock scenario.

    DISM /image:C:\ /optimize-image /boot
    
  4. Capture the Windows partition. For example:

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

    Where D: is a USB flash drive or other file storage location.

Apply the image

  1. Boot the device using Windows PE.

  2. Wipe the hard drive and set up new hard disk partitions using a script. Use CreatePartitions-UEFI.txt (or CreatePartitions-BIOS.txt for older, legacy BIOS devices).

    diskpart /s CreatePartitions-UEFI.txt
    
  3. Apply the images using a script.

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

Sample script

Below is an simple sample script that applies an image to a disk that's been partitioned using one of the hard disk partitioning scripts from step 2.

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 ==
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

Deploy Windows using Full Flash Update (FFU)

Capture and Apply Windows, System, and Recovery Partitions

Configure UEFI/GPT-Based Hard Drive Partitions

Configure BIOS/MBR-Based Hard Drive Partitions

BCDboot Command-Line Options

REAgentC Command-Line Options