Thursday, March 26, 2020

Using DISM to inject Windows updates into an image (.wim file)



Who is this for?


This is for anyone that uses Windows image files *wim.  If you don't then it might be best to look away :)

Background


To add updates to an image of Windows 10 will save time when it comes to deploying a new computer.  This technique will work with an MECM/SCCM deployment or WDS.  You should even be able to replace the WIM file in a boot USB device.  The advantage is that your freshly imaged computer will be delivered with the updates pre-installed.

Requirements

  • ISO file of the Windows 10 image that you want to update.  Note this assumes that there is only one image in the WIM file.  If there are multiple images in your WIM file you will need to export this before proceeding.  The information on how to do this can be found elsewhere.
  • Administrator access on the computer you will be performing this task
  • Reference computer built using your image fully updated from Microsoft Update.  This is used to get the list of required updates

Process

  1. Open an Administrator command prompt
  2. Type "C:" to confirm that you are working on the C: drive
  3. Type "MD C:\Temp".  This will create a folder called C:\Temp.  You can use another name if you choose, but you will need to alter your references accordingly.
  4. Type "CD \Temp" you should now be in your working folder
  5. Type "MD Updates" (To hold windows updates)
  6. Type "MD Mount" (working directory used by the DISM command)
  7. Go online to https://www.catalog.update.microsoft.com/home.aspx and type in the KB numbers that you want to add to your image.  For example 4497165 and then search. You will find the numbers on your reference computer under "View installed updates" in the Control Panel.
  8. Download the appropriate version for your Operating System and architecture (x86/x64 etc.) and place it into "C:\Temp\Updates".  Do this for all updates that you need to add to the image.
  9. Type "Notepad addUpdates.cmd" and then press enter.  You will be told that the file does not exist and would you like to create it.  
  10. Copy the following lines into addUpdates.cmd

    @echo On
    dism /mount-wim /wimfile:%1 /index:1 /mountdir:Mount
    dism /image:Mount /add-package /PackagePath:Updates
    dism /unmount-wim /mountdir:Mount /commit
    dism /Cleanup-Wim
  11. Close the file and click Yes to save the contents
  12. Right click on the ISO file and select mount.  Mine appeared as E: drive
  13. in your Administrator cmd prompt type "Copy E:\Sources\install.wim C:\Temp\Install.wim".  You may need to export your specific version of Windows 10 here as most Windows OS disks have multiple versions in the one WIM file
  14. It is best to call your WIM file something that identifies what it actually contains.  IE. Something like "w10Ent1909x64.wim" Would identify the file as containing Windows 10 Enterprise 1909 x64.  Use whatever naming convention makes sense to you.  Rename it now.
  15. in the cmd prompt type "addUpdates.cmd w10Ent1909x64.wim" replacing "w10Ent1909x64.wim" with the name of your WIM file.
Walk away for a while and your WIM file will be ready for delivery to a new computer.