- 1. Table of Contents
- 2. Requirements
- 3. Preparing the Build Environment
- 4. Removing Non-Essential Editions
- 5. Mounting the ISO
- 6. Integrating Drivers
- 7. Integrating Updates
- 8. Enabling .NET 3.5 (Windows 8+)
- 9. Modifying ISO Contents
- 10. Unmounting and Saving Changes
- 11. ISO Compression
- 12. Convert to ISO
-
Extraction tool - 7-Zip is recommended
-
Windows ADK - Install Deployment Tools
-
If Windows Defender is enabled, then consider disabling real-time protection as it can slow the mounting and unmounting process or cause issues in some cases
-
Open CMD as administrator and do not close the window as we will be setting temporary environment variables which will be unbound when the session is ended
-
Run the command below. If an error occurs, re-open CMD with administrator privileges however if nothing is shown in the output, continue to the next point
DISM > nul 2>&1 || echo error: administrator privileges required
-
Extract the contents of the ISO to a directory of your choice then assign it to the
EXTRACTED_ISO
variable. In the examples below, I'm usingC:\en_windows_7_professional_with_sp1_x64_dvd_u_676939
set "EXTRACTED_ISO=C:\en_windows_7_professional_with_sp1_x64_dvd_u_676939"
-
Set the path where the ISO will be mounted for servicing to the
MOUNT_DIR
variable. Changing the value below isn't necessaryset "MOUNT_DIR=%temp%\MOUNT_DIR"
-
Set the path to the
oscdimg.exe
binary to theOSCDIMG
variable. Unless you installed deployment tools to a location other than the default, changing the value below isn't necessaryset "OSCDIMG=C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\oscdimg.exe"
-
Prepare the
MOUNT_DIR
directory for mounting> nul 2>&1 (DISM /Unmount-Wim /MountDir:"%MOUNT_DIR%" /Discard & rd /s /q "%MOUNT_DIR%" & mkdir "%MOUNT_DIR%")
-
If the environment variables are configured correctly, the commands below should all display
true
if exist "%EXTRACTED_ISO%\sources\install.wim" (echo true) else (echo false)
if exist "%MOUNT_DIR%" (echo true) else (echo false)
if exist "%OSCDIMG%" (echo true) else (echo false)
Remove every edition except the desired edition by retrieving the indexes of every other edition and removing them with the commands below. Once completed, the only edition to exist should be the desired edition at index 1.
-
Get all available editions and their corresponding indexes
DISM /Get-WimInfo /WimFile:"%EXTRACTED_ISO%\sources\install.wim"
-
Remove edition by index. Replace
<index>
with the index numberDISM /Delete-Image /ImageFile:"%EXTRACTED_ISO%\sources\install.wim" /Index:<index>
Mount the ISO with the command below.
DISM /Mount-Wim /WimFile:"%EXTRACTED_ISO%\sources\install.wim" /Index:1 /MountDir:"%MOUNT_DIR%"
Place all the drivers that you want to integrate (if any) in a folder such as C:\drivers
and use the command below to integrate them into the mounted ISO.
DISM /Image:"%MOUNT_DIR%" /Add-Driver /Driver:"C:\drivers" /Recurse /ForceUnsigned
Integrate the updates into the mounted ISO with the command below. The servicing stack must be installed before installing any cumulative updates.
DISM /Image:"%MOUNT_DIR%" /Add-Package /PackagePath=<path\to\update>
.NET 3.5 can be enabled using the command below which a minority of applications depend on.
DISM /Image:"%MOUNT_DIR%" /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:"%EXTRACTED_ISO%\sources\sxs"
To modify the ISO contents, the directory can be opened with the command below.
explorer "%MOUNT_DIR%"
Run the command below to commit our changes to the ISO. If you get an error, check if the directory is empty to ensure the ISO is unmounted by typing explorer "%MOUNT_DIR%"
. If it is empty, you can likely ignore the error, otherwise try closing all open folders and running the command again.
DISM /Unmount-Wim /MountDir:"%MOUNT_DIR%" /Commit && rd /s /q "%MOUNT_DIR%"
Compressing has no advantage other than reducing the size. Keep in mind that Windows setup must decompress the ISO upon installation which takes time. Use the command below to compress the ISO.
DISM /Export-Image /SourceImageFile:"%EXTRACTED_ISO%\sources\install.wim" /SourceIndex:1 /DestinationImageFile:"%EXTRACTED_ISO%\sources\install.esd" /Compress:recovery /CheckIntegrity && del /f /q "%EXTRACTED_ISO%\sources\install.wim"
Use the command below to pack the extracted contents back to a single ISO which will be created in the C:
drive.
"%OSCDIMG%" -m -o -u2 -udfver102 -l"Final" -bootdata:2#p0,e,b"%EXTRACTED_ISO%\boot\etfsboot.com"#pEF,e,b"%EXTRACTED_ISO%\efi\microsoft\boot\efisys.bin" "%EXTRACTED_ISO%" "C:\Final.iso"