Batch – PowerShell – Inject Windows Updates into WIM

email me

Inject Windows Updates right into your WIM, aka slipstreaming.

Batch Method – Single or Multiple Updates

@echo off

:: add your update(s) here
set UDates=C:\MSUpdates

:: The mount path
set WMount=c:\WINMOUNT

:: Your WIM
set WIMPath=c:\image.wim

:: A single update
set SUpdate=windows10.0-kb3214628-x64-1511.msu

:: ————

:: Make folder
MD %UDates%

:: Make the mount folder
MD %WMount%

:: Command to mount wim to folder
DISM /Mount-Wim /WimFile:%WIMPath% /Index:1 /MountDir:%WMount%

:: Add a single update
:: DISM /image:%WMount% /Add-Package /Packagepath:%UDates%\%SUpdate%

:: Add multiple updates – do not add a specific update
Dism /image:%WMount% /Add-Package /PackagePath:%UDates%\

:: Save changes and unmount
DISM /Unmount-Wim /MountDir:%WMount% /Commit

:: Perform cleanup
DISM /Cleanup-Wim

Screenshot of script running

more info…
PowerShell Method – Multiple Updates

# Add all MSUs/CABs here
$UpdatesPath = "C:\MSUpdates\*"

# Windows will be mounted here
$MountPath = "C:\WINMOUNT"

# Your WIM file
$WimFile = "C:\image.wim"

# Mount command
DISM /Mount-Wim /WimFile:$WimFile /index:1 /Mountdir:$MountPath

# Load updates into array
$UpdateArray = Get-Item $UpdatesPath
ForEach ($Updates in $UpdateArray)
# Add update
DISM /image:$MountPath /Add-Package /Packagepath:$Updates
Start-Sleep –s 5
Write-Host "Microsoft updates have been added to WIM!"

# Unmount
DISM /Unmount-Wim /Mountdir:$MountPath /commit
DISM /Cleanup-Wim

Screenshot of script running