This is a follow-up to a previous post: Building a Windows 7 Image.
Why you may ask? Well, mainly for testing. If you are moving off of Windows 7 to Windows 10 finally, rapidly building Windows 7 is important for testing. Or, maybe you’re just unlucky enough to still have to deploy Windows 7. Either way, here are the updated items to slipstream into the base Windows 7 Service Pack 1 WIM image to have a nearly fully up to date image ready for deployment using your favorite WIM deployment tool.
What You’ll Need
- Windows 7 Service Pack 1 media
- It’s very important that it’s the SP1 media.
- Pro or Enterprise doesn’t matter.
- Internet Explorer 11 prerequisite updates
- There are 9 .msu files in total.
- Internet Explorer 11
- April 2015 servicing stack update for Windows 7 and Windows Server 2008 R2
- Convenience rollup update for Windows 7 SP1 and Windows Server 2008 R2 SP1
- SHA-2 code signing support update
- Servicing stack update for Windows 7 SP1 and Windows Server 2008 R2 SP1: March 12, 2019
- Servicing stack update for Windows 7 SP1 and Server 2008 R2 SP1: November 12, 2019
- Update for the d3dcompiler_47.dll component on Windows Server 2012, Windows 7, and Windows Server 2008 R2
- The latest Windows 7 monthly rollup.
- As of November 2019, this is KB4525235
- The latest cumulative update for Internet Explorer 11
- As of November 2019, this is KB4525106
- The latest security and quality rollup for .NET framework 3.5.1
- As of November 2019, this KB4507004 (from July 2019)
I don’t know of any other applicable, one-off updates as these have all been incorporated into the monthly rollups to my knowledge. Unfortunately, the .NET Framework 4.7.1 and Windows Management Framework 5.1 cannot be directly injected so these must come after the image is deployed if necessary.
- Prepare a working folder on a system running with the ADK installed and where DISM is available.
- Download all of the updates listed above and place them into the working folder All of the files except the Internet Explorer 11 download are MSU files. I highly suggest placing the updates in sub-folders named for the update’s title for organizational purposes. What you call these folders and if you actually create them is up to you though.
- Mount the Windows 7 Service Pack 1 media and copy the image.wim file from the sources sub-directory to the working folder. image.wim is the largest file and easy to find if you sort by size. Alternatively, use a tool like 7-zip to simply extract this file.
- (Optional) Rename image.wim to something meaningful like Win7-SP1-Ent-x64-media-Nov2019.wim. Note that nov2019 in the file name reflects when we are updating the image so that you can distinguish it from past builds and know when you created it.
- (Optional) Create a subfolder of the working folder called Images. Move the .wim file to the Image sub-folder.
- Using the command line, extract the Internet Explorer 11 files to the working folder or a sub-folder of the working folder: IE11-Windows6.1-x64-en-us.exe /x:<path_to_working_folder>/<subfolder>
- Create batch file with the below code in the working folder; call it Win7Image-Update.bat.
- Run the batch file from the command line or PowerShell:
Win7Image-Update.bat <path_to_WIM_file><path_to_empty_folder> [WhatIf].
Specify the location to the base image and an empty folder to mount the WIM to (note that the batch file does not check to see if this folder is empty but DISM will). You can also specify WhatIf as the third parameter to see what the batch file will do.
Example: Win7Image-Update.bat .\Images\Win7-SP1-Ent-x64-media-Nov2019.wim F:\Mount
Make sure to enclose paths with spaces in double-quotes.
@ECHO OFF SETLOCAL EnableDelayedExpansion IF [%1]== GOTO USAGE IF [%2]== GOTO USAGE IF EXIST %1 ( GOTO PROCESS ) ELSE ( GOTO FILENOTFOUND ) :PROCESS IF NOT [%3]==[WhatIf] ( ECHO Processing ... SET WHATIF=0 ) ELSE ( ECHO Processing in WhatIf mode ... SET WHATIF=1 ) SET IMAGEPATH=%~1 SET MOUNTPATH=%~2 IF %MOUNTPATH:~-1%==\ SET MOUNTPATH=%MOUNTPATH:~0,-1% SET IE11PREREQS=2533623 2639308 2670838 2729094 2731771 2786081 2834140 2882822 2888049 SET IE11=IE-Win7 IE-Hyphenation-en IE-Spelling-en SET WINDOWS7=4474419 3020369 3125574 4490628 4523206 4525235 SET IECU=4525106 SET DOTNET=4019990 4507004 SET UPDATES=IE11PREREQS IE11 WINDOWS7 IECU DOTNET SET ALLFOUND=1 FOR %%H in (%UPDATES%) DO ( SET UPDATELIST=!%%H! CALL :CHECKUPDATES ) IF [%ALLFOUND%]== GOTO UPDATESNOTFOUND ECHO All update were found. Beginning installation. ECHO. pause ECHO Mounting WIM image at '%~1' ECHO ------------------------------------------------------------------------------- IF [%WHATIF%]== ( ECHO dism /mount-wim /index:1 /wimfile:"%IMAGEPATH%" /mountdir:"%MOUNTPATH%" ) ELSE ( dism /mount-wim /index:1 /wimfile:"%IMAGEPATH%" /mountdir:"%MOUNTPATH%" ) ECHO. FOR %%H in (%UPDATES%) DO ( SET UPDATELIST=!%%H! CALL :INSTALLUPDATES ) ECHO Unmounting WIM image at '%MOUNTPATH%' ECHO ------------------------------------------------------------------------------- IF [%WHATIF%]== ( ECHO dism /unmount-wim /mountdir:"%MOUNTPATH%" /commit ) ELSE ( dism /unmount-wim /mountdir:"%MOUNTPATH%" /commit ) ECHO. GOTO END :CHECKUPDATES FOR %%a in (!UPDATELIST!) DO ( ECHO %%a SET FOUND= FOR /R .\ %%G IN (*%%a*.msu,*%%a*.cab) DO ( SET FOUND=%%G ) IF [!FOUND!]== ( ECHO Not found: %%a SET ALLFOUND=0 ) ) GOTO :EOF :INSTALLUPDATES ECHO ------------------------------------------------------------------------------- FOR %%a in (%UPDATELIST%) DO ( ECHO %%a SET FOUND= FOR /R .\ %%G IN (*%%a*.msu,*%%a*.cab) DO ( IF [%WHATIF%]== ( ECHO dism /image:"%MOUNTPATH%" /add-package /packagepath:"%%G" ) ELSE ( dism /image:"%MOUNTPATH%" /add-package /packagepath:"%%G" ) SET FOUND=%%G ) IF [!FOUND!]== ECHO Not found: %%a ) ECHO. GOTO :EOF :USAGE ECHO Usage: %~nx0 ImageFilename MountDirectory [WhatIf] EXIT 1 :FILENOTFOUND ECHO The file '%~1' was not found. EXIT 2 :UPDATESNOTFOUND ECHO. ECHO Some updates were not found. Exiting. ECHO. EXIT 2 :END
What the Batch File Does
- Defines the updates in five variables. The values in the five variables are search strings used to search all subfolders for the updates. The search strings are mostly KB article numbers as these are contained in all of the filenames except for the main Internet Explorer filenames. Note also that all of the updates except the main Internet Explorer installation file are MSU files; the main Internet Explorer installation file is a CAB file.
- Finds and checks for the existence of all of the necessary updates using the values defined in the five variables regardless of which sub-folder the updates are in.
- Mounts the image.
- Installs the updates in the order defined in the five variables. Keep in mind that the order of the updates is very important; it took me a few hours of trial and error to find the correct order.
- Unmounts the image.
Well, that’s up to you. You can pick up in step 3 of the previous Building a Windows 7 Image article or deploy the WIM with whatever tool you’d prefer.
Is this all overkill for Windows 7? Yes. But if you’re testing your upgrade or migration to Windows 10, re-building systems with Windows 7 rapidly is important.
Is using a batch file for this kind of crazy? Kind of. It works well though. Feel free to re-write it in PowerShell if you prefer. I thought about it a few times as I was writing it but ended just sticking with the batch file. There are a few things that would certainly have been easier and more succinct in PowerShell, but it works quite well as a batch also.
Kind of like Monty Python and the Holy Grail, Windows 7 ain’t dead yet.
This is great. I was looking at doing the same thing. Note the April 2015 SSU goes to a 404 page so I just went to the update catalog and searched for KB3020369.
Optionally, would be to get the ASROCK, ASUS, or MSI Windows 7 tool as they will inject more current Intel and/or AMD chipset drivers into the boot.wim.