Customizing the Windows Installer Media

Overview

Modern Windows operating system deployment typically depends on network and server infrastructure services like Microsoft Endpoint Configuration Manager (formerly known as SCCM).

What if you need to deploy in an environment that does not have these tools?

This article details the process for customizing the Windows installer ISO to incorporate an answer file, allowing you to consistently deploy the operating system without network and server resources. This process should work well for any modern Windows release including Home, Pro, and Enterprise 10 and 11; and Server 2016, 2019, and 2022.

You can use our OZO Windows Installer Customizer automation script to manage your Windows installer ISO customization needs.

Prerequisite Set Up

Software Environment

Download and the latest Microsoft Assessment and Deployment Kit and select the Deployment Tools​​​​​​​ feature during installation. This kit provides the Windows System Image Manager (“SIM”), and the Deployment and Imaging Tools Environment required for this process.

Working Directories

Create the following directory structure. You may choose a different location (such as your user profile) but avoid using a path that includes spaces (due to a limitation of oscdimg.exe).

DirectoryDescription
C:\ImagingParent directory for all Imaging assets
C:\Imaging\DriversLocation for storing 3rd party drivers
C:\Imaging\DVDLocation for storing the contents of the Microsoft Windows DVD ISO
C:\Imaging\ISOOutput location for customized ISOs
C:\Imaging\MediaLocation for storing logo.png, icon.png, and wallpaper.png referenced in the answer file
C:\Imaging\MountLocation for mounting WIM files
C:\Imaging\WIMLocation for storing WIM and associated catalog file

Obtain Windows Installer Media

  1. See Create installation media for Windows to obtain a Windows ISO.
  2. Double-click (mount) the ISO and copy the contents to C:\Imaging\DVD\.
  3. Eject (unmount) the DVD ISO.
  4. Move C:\DVD\sources\install.wim to C:\Imaging\WIM\.

Obtain 3rd Party Drivers

Obtain any drivers you wish to preload and extract them to individual subdirectories of C:\Imaging\Drivers\. You can use 7-Zip to extract drivers from CAB files.

Create a Catalog and Answer File

Answer files are a complicated topic worthy of their own article. Use this and Microsoft’s guidance on Answer files to decide which components and features will suit your needs.

  1. Open Windows SIM as Administrator.
  2. File > Select Windows Image > C:\Imaging\WIM\install.wim
  3. Choose your desired edition e.g., Home, Pro, Enterprise, etc.
  4. Click Yes to create a catalog.
  5. File > New Answer File > C:\Imaging\DVD\Autounattend.xml
  6. Populate your answer file as desired.
  7. Save and close the answer file, windows image, and Windows SIM.

Determine the Edition Index

Open an Administrator PowerShell and execute:

Get-WindowsImage -ImagePath "C:\Imaging\WIM\install.wim"

Note the Index number of your desired edition; this will be referred to as [INDEX] in the following steps.

Customization Procedure

Perform these steps in an Administrator PowerShell.

Export the Edition to a New WIM

In this step, we export the desired [INDEX] from install.wim to a new WIM.

Export-WindowsImage -SourceImagePath "C:\Imaging\WIM\install.wim" -SourceIndex [INDEX] -DestinationImagePath "C:\Imaging\DVD\sources\install.wim"

Mount the Exported WIM

In this step, we mount the newly exported WIM. This new WIM contains only the exported edition, so the index will now be “1”.

Mount-WindowsImage -ImagePath  "C:\Imaging\DVD\sources\install.wim" -Index 1 -Path "C:\Imaging\Mount"

Add Drivers

Here we add drivers to the WIM. This command is recursive so be sure your C:\Imaging\Drivers directory contains only the desired drivers.

Add-WindowsDriver -Recurse -Path "C:\Imaging\Mount" -Driver "C:\Imaging\Drivers"

[Optional] Copy Media Assets

If your answer file references any OEM media for e.g., custom logos or wallpaper, they will be copied in this step.

New-Item -ItemType Directory -Path "C:\Imaging\Mount\Windows\System32\OEM"
Copy-Item -Path "C:\Imaging\Media\*.*" -Destination "C:\Imaging\Mount\Windows\System32\OEM\"

[Optional] Create a List of Undesired AppX Packages

Windows includes a number of Appx packages that you may wish to remove to suit your environment. Use the following PowerShell command to list all installed Appx packages. Enumerate the AppX Packages and make a note of which packages to remove:

(Get-AppxProvisionedPackage -Path "C:\Imaging\Mount").DisplayName

[Optional] Remove AppX packages

Refer to your list of undesired Appx packages created above. Run this command once for each package you wish to remove, substituting the full package name for [APPX]. You may consider scripting this step as described in Removing AppX Packages with PowerShell.

Remove-AppxProvisionedPackages -Path "C:\Imaging\Mount" -PackageName [APPX]

Unmount the Image

Dismount-WindowsImage -Save -Path "C:\Imaging\Mount"

Create Custom ISO

Open the Deployment and Imaging Tools Environment shell as Administrator and execute the following:

oscdimg.exe -u2 -udfver102 -t -lCustom-Windows -bC:\Imaging\DVD\efi\microsoft\boot\efisys.bin C:\Imaging\DVD\ C:\Imaging\ISO\Custom-Windows.iso

Here’s a breakdown of this command:

ArgumentDescription
-u2Produces an image containing only the UDF file system
-udfver102Writes UDF revision 1.02
-tSpecifies the El Torito load segment
-lCustom-WindowsSpecifies the volume label
-bC:\Imaging\DVD\efi\microsoft\boot\efisys.binSpecifies the path to the file that will be written to the boot sector
C:\Imaging\DVDPath containing the source files
C:\Imaging\ISO\Custom-Windows.isoOutput location for ISO file

Conclusion

Now you should have C:\Imaging\ISO\Custom-Windows.iso that you can write to DVD or to USB media using Rufus or balenaEtcher. Depending on the information you included in your answer file, you may have created a hands-free way to deploy your desired Windows configuration.