How to Craft Your Own Custom Windows Image with Pre-Installed Applications

In this guide, we’ll cover how to create a custom Windows 10/11 installation image with pre-installed apps, necessary files, and other environment and application settings. Currently, many admins prefer to deploy a clean Windows image and then install all the required programs and tools on the computer: deploy software via GPO, using the installation commands in AutoUnattend.xml or in the %WINDIR%SetupScriptsSetupComplete.cmd script (allow to install software during OOBE), GPO logon scripts. or using other automation tools (SCCM, Intune, MDT, Ansible). However, in some cases, business specifics require that a pre-built Windows image with all the necessary programs be deployed to end-user computers.

The process of creating your custom Windows installation image with pre-installed software can include the following steps:

  1. Deploy a clean Windows instance on a reference computer (virtual machine);
  2. Boot Windows in audit mode, install the apps, configure the environment;
  3. Boot the device into the WinPE environment and capture the WIM image of the installed Windows using DISM;
  4. Replace the original install.wim on the installation USB flash drive (ISO image).

If you are deploying Windows to computers on a corporate network, it is more convenient to use MDT, which allows you to add/update programs during the installation process without having to modify the installation WIM image each time.

Building a Reference Windows Image with Pre-installed Software

The first step is to create a reference image of Windows with all the programs, files, and settings you need. Perform a clean Windows installation on a virtual machine or computer.

Download the original Windows 10/11 installation image as an ISO file or burn it directly to a bootable USB flash drive using the Media Creation Tool or Rufus.

Perform a manual Windows installation and press CTRL+SHIFT+F3 at the OOBE stage (when prompted to select regional settings). This will put the computer into Audit Mode, and you will be automatically logged in as the built-in Administrator account.

When the desktop appears, minimize the Sysprep window (don’t close it!!). Then you can start installing programs and updates, and configuring the necessary Windows settings.

I will use the WinGet package manager to install various apps and tools on Windows:

winget install --id=7zip.7zip -e ; winget install --id=Notepad++.Notepad++ -e ; winget install --id=VideoLAN.VLC -e ; winget install --id=WinDirStat.WinDirStat -e ; winget install --id=dotPDNLLC.paintdotnet -e ; winget install --id=IrfanSkiljan.IrfanView -e ; winget install --id=Microsoft.PowerToys -e

I also manually created directories and copied files for several business apps.

Customize desktop shortcuts, Start menu tiles, wallpapers, screensavers, color schemes, and more. Configure local Group Policy settings using the gpedit.msc editor. These settings will be applied to all computers that you deploy from this custom Windows image.

Once the operating system and applications are installed, it is required to clean up Windows to minimize the end image size.

Eliminate the existing shadow copies and restore points:

vssadmin delete shadows /All /Quiet

Purge unused components and update files in the WinSxS folder:

Dism.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase

Remove the Windows Update cache files:

del %windir%SoftwareDistributionDownload*.* /f /s /q

You can use this PowerShell script to clean up the Temp, Downloads, and Cache folders in the user profile.

Perform a disk cleanup using the cleanmgr tool:

Cleanmgr /sagerun:1

Clear Event Viewer logs:

for /F "tokens=*" %1 in ('wevtutil.exe el') DO wevtutil.exe cl "%1"

Empty the Recycle Bin in Windows:

Clear-RecycleBin -Force

To apply the existing user settings to the Default user, which serves as a model for creating new users in Windows, generate an unattend.xml answer file within the C:WindowsSystem32Sysprep directory.

<?xml version="1.0" encoding="utf-8"?>

<unattend xmlns="urn:schemas-microsoft-com:unattend">

<settings pass="specialize">

<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<CopyProfile>true</CopyProfile>

</component>

</settings>

</unattend>

The last step is preparing your customized Windows image for deployment using the sysprep.exe tool. Open the Sysprep window and select the options mentioned below:

  • Initiate System Out-of-Box Experience (OOBE)
  • Generalize
  • Shutdown

When this process is complete, the computer will automatically shut down.

Capture a Custom Windows Image Using DISM

At this stage, you will need to capture an offline Windows image from a local drive, save it as a WIM file, and place it on a separate drive (we connected a separate 60GB empty drive to the computer).

Boot the computer with the referenced Windows image into the WinPE environment

WinRE).

Using the Windows installation USB stick, boot the computer and press Shift+F10 to open the command prompt.

Identify the drive letters designated to the Windows partition and the unoccupied drive where the WIM file will be transferred. Execute the following command:

diskpart
list disk
exit

In the stated example, the drive hosting Windows is assigned the letter E: and the blank drive is labeled as D:.

To seize an offline Windows image from the E drive and preserve the resulting WIM image to the D drive, implement the command:

dism /capture-image /imagefile:D:install.wim /capturedir:E: /ScratchDir:D: /name:"MyWinImage" /compress:maximum /checkintegrity /verify /bootable

It took about 30 minutes to capture the image in my case.

Replace the Original Install.wim Image File on the USB Flash Drive

Once you have captured your customized Windows image, you can replace the original install.wim or install.esd image file in the sources folder on the installation USB flash drive.

ESD is the maximum compression format used for WIM.

I made a change to the old image file name to install.esd_bak and duplicated the new install.wim image onto the USB device.

Keep in mind that the WIM image dimension, inclusive of pre-installed software, has expanded significantly (from 4GB to 10GB).

Consiodering you possess a FAT32 bootable USB device for installing Windows on UEFI devices, it is impossible to save a WIM file larger than 4GB on this kind of file system. In this situation, a chunky WIM image file has to be fragmented into multiple smaller SWM files:

Dism /Split-Image /ImageFile:D:sourcesinstall.wim /SWMFile:c:tmpinstall.swm /FileSize:3500

In this scenario, DISM formulates four files namely install.swm, install2.swm, install3.swm, and install4.swm. It’s advisable to transfer these files to the sources directory on the installation medium. When the Windows Setup begins the OS installation, it brings together the SWM files.

You are now equipped to use your bootable USB flash drive to deploy the Windows image that you have crafted to any computer (the alternative option is to install Windows across the network using PXE boot).

Ensure that every preinstalled app is available following the full Windows installation:

Get-Package

The downside of this method of deploying a preconfigured Windows image is that you have to rebuild the image to update any of the apps it contains.

Windows Updates and drivers can be integrated directly into the WIM image. In this case, there is no need to go through the full deployment and image capture cycle.


Posted

in

,

by

Tags: