Today we’ll show how to integrate Windows updates into the offline image of Windows 8 / Server 2012 using DISM.
We need: offline image of Windows 8 and Windows updates in .msu format (can be download from Microsoft website). It’s important to make sure that the your Windows OS image and the updates have the same bitness and version.
Let’s create the following directory structure:
- C:\updates\mnt is the folder in which the Windows image file install.wim will be mounted
- C:\updates\msu is a folder with the updates in .MSU format (as an example, we have downloaded 5 Windows 8 security updates issued in February as a part of MS Patch Tuesday).
- C:\updates\Win8-64-16134\ is a directory to which install.wim from the offline Windows 8 image should be copied. In our example, we mount and unpack the contents of the original Windows 8 distribution image SW_DVD5_Win_Pro_8_64BIT_English_MLF_X18-16134.ISO to it. In practice, it can be, for instance, a WIM file of a virtual machine or its template, or a WIM file of a WDS image, or a template that is stored in another system of automated deployment.
Mount the Windows 8 image file install.wim to C:\updates\mnt by running the following command in the command line under the administrator privileges:
dism /mount-wim /wimfile:C:\updates\Win8-64-16134\sources\install.wim /index:1 /mountdir:C:\updates\mnt
Get-WindowsImage -ImagePath C:\updates\Win8-64-16134\sources\install.wim
In our example, the image contains only one OS edition – Windows 8 Pro version with the index 1, so we specify install.wim /index:1 in the command.
The next command will start integrating the suitable updates located in the specified folder into the image. If the system detects a wrong update (a one that is not suitable for this OS version and bitness, or if the update is already installed), it will be ignored and the corresponding information will be written to C:\Windows\Logs\DISM\dism.log.
dism /image:C:\updates\mnt /add-package /packagepath:C:\updates\msu
If you have a computer with all necessary updates installed, all the necessary update files can be obtained directly from it, without downloading them from the Internet. The trick is that Windows saves CAB files of the updates that have been downloaded from Windows Update servers or a WSUS server to C:\Windows\SoftwareDistribution\Download folder.
The command to integrate updates installed on another computer under the name Win8x64AlreadyPatched into the image install.wim looks like that:
Start /w for /R \\Win8x64AlreadyPatched\C$\Windows\SoftwareDistribution\Download\ %f in (*.cab) do dism /image:C:\updates\mnt /add-package /packagepath:”%f”
And the last step is to save the changes and unmount the mounted Windows 8 image.
dism /unmount-wim /mountdir:C:\updates\mnt /commit
You only have to copy install.wim to the source directory/virtual machine or rebuild the installation ISO image, e. g., using oscdimg or UltraISO.