Customizing the Windows Installer Media

By | 2022-Jan-04

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 Windows 10 or 11.

Prerequisite Set Up

Software Environment

Download and install the latest Microsoft Assessment and Deployment Kit. Select the Deployment Tools​​​​​​​ feature during installation. This kit provides the Windows System Image Manager (“SIM”); and Deployment and Imaging Tools Environment (including dism.exe and oscdimg.exe) tools 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 directory path that includes spaces.

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 List of Undesired Appx Packages (optional)

Windows includes a handful of preloaded Appx packages that you may wish to remove to suit your environment. Perform a temporary manual installation of your target edition (be sure to do this offline to avoid updates) and use the following PowerShell command to list all installed Appx packages. Make a list of any you wish to remove. These will be referred to as [APPX] in future steps.

> Get-AppxProvisionedPackages -Online

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

  1. Open the Deployment and Imaging Tools Environment as Administrator.
  2. Execute Dism /Get-WimInfo /WimFile:"C:\Imaging\WIM\install.wim"
  3. Find your edition and note the Index number. This will be referred to as [INDEX] in the next steps.

Procedure

Open the Deployment and Imaging Tools Environment as Administrator for the following steps.

Export the Edition

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

> Dism /Export-Image /SourceImageFile:"C:\Imaging\WIM\install.wim" /SourceIndex:[INDEX] /DestinationImageFile:"C:\Imaging\DVD\sources\install.wim"

Mount the Image

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

> Dism /Mount-Image /ImageFile:"C:\Imaging\DVD\sources\install.wim" /Index:1  /MountDir:"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.

> Dism /Add-Driver /Image:"C:\Imaging\Mount" /Driver:"C:\Imaging\Drivers" /recurse

Copy Media Assets (optional)

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

> md "C:\Imaging\Mount\Windows\System32\OEM"
> copy "C:\Imaging\Media\*.*" "C:\Imaging\Mount\Windows\System32\OEM\"

Remove Undesired 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

Dism /Unmount-Image /MountDir:"C:\Imaging\Mount" /Commit

Create Custom ISO

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

One thought on “Customizing the Windows Installer Media

  1. Pingback: Common Elements for Windows Answer Files – One Zero One

Comments are closed.