Wednesday, November 27, 2024

Add Windows Updates to a Windows 7 SP1 image

To speed up an Windows 7 installation it is possible to include all Windows updates directly to the installation (so called splipstream in the past). This howto explains the needed steps here.

Preparation:

– Create “C:\Update_Windows_7_Image”

– Create “C:\Update_Windows_7_Image\Mounted”

– Install a Windows 7 OS, then check which updates are missing and download the updates and store them inside C:\Update_Windows_7_Image\PendingWindowsUpdates

– Install the Windows Assessment and Deployment Kit (ADS) for Windows 8.1 update (from here) [Select the components “Deployment Tools” during installation]

 

Implementation steps:

1.) Extract a original Windows 7 SP1 ISO image to C:\Update_Windows_7_Image\Extracted (e.g. via WinRar)

2.) Optional: As some updates couldn´t be automatically be installed via the steps outlined below we will make use from the $OEM$ folder and the FirstLoginCommands.

2a.) To use that create an $OEM$ folder inside “C:\Update_Windows_7_Image\Extracted\sources”.

2b.) Inside the $OEM$ folder create the following folders “$$\Setup\Scripts”

2c.) Inside the scripts folder create a FirstRun.cmd with the following inside it:

for %%i in (b c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%i:\FirstRun\FirstRun.bat %%i:\FirstRun\FirstRun.bat
)

This script is triggered the first time a user login (preferred the admin, otherwise it might not work due to missing admin rights). It will then check multiple drives and if there exists a firstrun.bat (which we will create later) it will run the batch file.

2d.) Then go to “C:\Update_Windows_7_Image\Extracted\source\$OEM$” and create an folder called “$1”. Everything inside that folder will be copied to the root drive where MS Windows will be installed.

2e.) Inside that folder (C:\Update_Windows_7_Image\Extracted\source\$OEM$\$1) create a new folder called FirstRun and inside that a file called FirstRun.bat with the following content:

@Echo Off

3.) As the *.MSU files are nothing else as a kind of ZIP files we will extract them now at first, so that this step must not be done later one during the integration. This often speeds up the installation. The following powershell script will do that

$ExtractionFolder="C:\Update_Windows_7_Image\ToBeIntegratedWindowsUpdates"
$PendingHotfixes=(Get-Item -Path "C:\Update_Windows_7_Image\PendingWindowsUpdates").FullName

Foreach($item in (ls $PendingHotfixes *.msu -Name))
{
echo "-----------------------------------------------------"
echo Extracting: $item
echo " "
$item = $PendingHotfixes + "\" + $item
Expand –F:* $item $ExtractionFolder
echo "-----------------------------------------------------"
}

remove-item $ExtractionFolder\*.txt -Confirm:$false -Force
remove-item $ExtractionFolder\*.exe -Confirm:$false -Force
remove-item $ExtractionFolder\*.xml -Confirm:$false -Force
remove-item $ExtractionFolder\WSUSSCAN.cab -Confirm:$false -Force

4.) As a install.wim can contain multiple images we need to check at first the possible indexes.

4a.) To do that start an CMD (as admin)

4b.) then switch to the 8.1 dism folder via

cd “C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\x86\DISM”

if you do not perform this step you might still use an old dism version (e.g. 6.1.7600.16385 on Windows 7; but we need at least 6.3.9600.17029 for this howto)

4c.) then run run

dism /get-wiminfo /wimfile:”C:\Update_Windows_7_Image\Extracted\sources\install.wim”

In our example here it will output the following:

Index : 1
Name : Windows 7 HOMEBASIC
Description : Windows 7 HOMEBASIC
Size : 15,481,701,439 bytes

Index : 2
Name : Windows 7 HOMEPREMIUM
Description : Windows 7 HOMEPREMIUM
Size : 15,985,441,609 bytes

Index : 3
Name : Windows 7 PROFESSIONAL
Description : Windows 7 PROFESSIONAL
Size : 15,887,888,732 bytes

Index : 4
Name : Windows 7 ULTIMATE
Description : Windows 7 ULTIMATE
Size : 16,048,236,531 bytes

Index : 4
Name : Windows 7 PROFESSIONALN
Description : Windows 7 PROFESSIONAL N
Size : 15,887,888,732 bytes

5.) Depending on which version we wish to “update” we need to use the correct index. In this example here we will update all versions in the image, so we will use a batch script which runs true all 5 indexes above and performs the same step for all of them (this will not result in a very big file).

If your install.wim showed only 4 indexes, then remove the nr 5 from the 4rd line in the script below.

So create a empty CMD named “integrate_updates.cmd” inside C:\Update_Windows_7_Image with the following content:

@echo off
CLS
dism /cleanup-wim
for %%a in (1 2 3 4 5) do (
Echo [--------------------------- Mount Image ---------------------------]
"C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\x86\DISM\dism.exe" /mount-wim /wimfile:C:\Update_Windows_7_Image\Extracted\sources\install.wim /index:%%a /mountdir:C:\Update_Windows_7_Image\Mounted

Echo [--------------------------- Add Windows 7 Updates ---------------------------]
"C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\x86\DISM\dism.exe" /image:C:\Update_Windows_7_Image\Mounted /add-package /packagepath:C:\Update_Windows_7_Image\ToBeIntegratedWindowsUpdates

Echo [--------------------------- Commit changes ---------------------------]
"C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\x86\DISM\dism.exe" /unmount-wim /mountdir:C:\Update_Windows_7_Image\Mounted /commit
)

Note: It would be possible to download all *.CAB files from a fresh installed Windows 7 OS from the folder C:\Windows\SoftwareDistribution\Download\ and put them into C:\Update_Windows_7_Image\PendingWindowsUpdates. But as Microsoft sometimes re-release hotfixes and the fact that the cleanup agent might delete these files, it should be a fresh installed Windows OS where you fetch the files from.

If something failed you can run dism /unmount-wim /mountdir:C:\Update_Windows_7_Image\Mounted /Discard

6.) Optional: As the image we are working on is include multiple versions from Windows but do not allow us to choose the version we need during the installation (e.g. Choose ultimate or professional) we will adjust that now, so that we can choose the version during the next installation. To enable the additional dialog the optional ei.cfg in the source folder (C:\Update_Windows_7_Image\Extracted\sources) [see here for more infos] must be deleted. If that file is no longer exists an additional dialog box appears during installation and will ask us to choose the Windows version we need. This might be useful if you own multiple PCs and wish to install MS Windows 7 Home on one PC and Ultimate on the other. So this change here would switch the installation image into a kind of “universal installation disk”.

Keep noted that you still need the correct activation key. If you have an Windows 7 Home key, it will not work when you choose ultimate during the installation and via versa.

7.) Inside our still open CMD we will run the script now via:

C:\Update_Windows_7_Image\integrate_updates.cmd

Depending on your PC this might take a while. Keep noted that you should not open the explorer and browse the folders for that project here as that might cause issues in the DISM process!

Which will import all our updates now into the image. Depending on the amount of updates and performance from your PC this might take some time.

8.) Optional: There are some updates which couldn´t be imported via the method above. If you try that (also via the script above) you will get multiple error messages via DISM like:

The specified package cannot be added to an offline image.
Add this package to a running operating system using the /Online option.
 Error: 0x800f082e

Those updates are the following (feel free to share your solution or others updates which are causing issues in the comments):

– KB2533552

To include these updates in our Windows 7 installation image we need to perform the following:

8a.) Download the *.msu files and store them inside the following folder (C:\Update_Windows_7_Image\Extracted\$OEM$\$1\FirstRun\Updates).

8b.) Now edit our FirstRun.bat (not the FirstRun.cmd) and for each of the updates which couldn´t be installed enter a similar line as below:

echo              Installing KB 2533552 ...
echo.

START /WAIT "%~dp0Updates\Windows6.1-KB2533552-x64.msu" /quiet /norestart

The %~dp0 (that’s a zero) variable, when referenced within a Windows batch file, will expand to the drive letter and path of that batch file

9.) Optional: Via the FirstRun.bat you can now also install the latest .net Framework (for example 4.7). Simply add the following lines to the FirstRun.cmd and store the .net Framework 4.7 installer (NDP47-KB3186497-x86-x64-AllOS-ENU.exe) inside the folder C:\Update_Windows_7_Image\Extracted\$OEM$\$1\FirstRun\netFrameworkUpdate

echo              Installing .net Framework 4.7 ...
echo.

START /WAIT "%~dp0netFrameworkUpdate\NDP47-KB3186497-x86-x64-AllOS-ENU.exe" /q /norestart

10.) Optional: Via the FirstRun.bat you can now also install the latestManagement Framework  (for example 5.0) as this required an .net Framework 4.5. or higher, which you just installed. Simply add the following lines to the FirstRun.cmd and store the .net Framework 4.7 installer (Win7AndW2K8R2-KB3191566-x64.msu) inside the folder C:\Update_Windows_7_Image\Extracted\$OEM$\$1\FirstRun\netFrameworkUpdate

echo              Installing Management Framework 5.0 ...
echo.

START /WAIT "%~dp0netFrameworkUpdate\Win7AndW2K8R2-KB3191566-x64.msu" /quit /norestart

11.) Optional: Out of the box the FirstRun.cmd isn´t triggered. So inside the C:\Update_Windows_7_Image\Extracted folder we need to create now a autounattend.xml with the following content:

 

 

12.) Optional: If you perform the tasks here multiple times over and over you might recognize that your image will grow in size. To change that you need to export the image in order to see a change/reduction in the file size. During the export process, DISM removes files that were superseded. Additional you can also specify the compress option (default is fast) and use maximum here.

If you do not use the AIK 8.1 folder, then DISM will have the version  6.1.7600.16385 which do not have this feature and will cause an error 87!

To do that we export every index to the new image. So save the following to C:\Update_Windows_7_Image\compress_image.ps1 and run it.

cd "C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\amd64\DISM"

./dism.exe /Export-Image /SourceImageFile:C:\Update_Windows_7_Image\Extracted\sources\install.wim /SourceIndex:1 /DestinationImageFile:C:\Update_Windows_7_Image\Extracted\sources\install-NEW.wim /DestinationName:"Windows 7 HOMEBASIC" /compress:maximum

./dism.exe /Export-Image /SourceImageFile:C:\Update_Windows_7_Image\Extracted\sources\install.wim /SourceIndex:2 /DestinationImageFile:C:\Update_Windows_7_Image\Extracted\sources\install-NEW.wim /DestinationName:"Windows 7 HOMEPREMIUM" /compress:maximum

./dism.exe /Export-Image /SourceImageFile:C:\Update_Windows_7_Image\Extracted\sources\install.wim /SourceIndex:3 /DestinationImageFile:C:\Update_Windows_7_Image\Extracted\sources\install-NEW.wim /DestinationName:"Windows 7 PROFESSIONAL" /compress:maximum

./dism.exe /Export-Image /SourceImageFile:C:\Update_Windows_7_Image\Extracted\sources\install.wim /SourceIndex:4 /DestinationImageFile:C:\Update_Windows_7_Image\Extracted\sources\install-NEW.wim /DestinationName:"Windows 7 ULTIMATE" /compress:maximum

./dism.exe /Export-Image /SourceImageFile:C:\Update_Windows_7_Image\Extracted\sources\install.wim /SourceIndex:5 /DestinationImageFile:C:\Update_Windows_7_Image\Extracted\sources\install-NEW.wim /DestinationName:"Windows 7 PROFESSIONAL N" /compress:maximum

If you shrink the image you can also export only one index (for example index 4, the ultimate version)

In that example here it decrease the needed space from 4.9GB to 4.3GB which will allow us again to burn the image on a normal DVD.

13.) We can then delete the original C:\Update_Windows_7_Image\Extracted\sources\install.wim and rename our install-NEW.wim to install.wim (or better move that to a backup place, but remove that from the extracted folder!).

14.) After that we will create our new ISO (so create an folder called “ISO” inside “C:\Update_Windows_7_Image”). So switch to the OSCDimg folder (C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg). Inside that folder run the following command:

oscdimg /b”C:\Update_Windows_7_Image\extracted\boot\etfsboot.com” /h /lWin7Universal_DVD /u2 /o C:\Update_Windows_7_Image\extracted C:\Update_Windows_7_Image\ISO\Windows7UniversalISO_-_WithUpdates.iso

This will create our new ISO, which we can use in VMWare to test it or directly burn to a DVD.

15.) Once you tested your ISO you can burn that to a DVD to install Windows PCs with it.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Stay Connected

35FollowersFollow
- Advertisement -

Latest Articles