Before you start
Objectives: demonstration on how to use DISM to update existing Windows 7 image.
Prerequisites: you have to have WAIK installed. You also have to know what is DISM.
Key terms: image, mount, dism, install, package, command, deployment, update, msu, mount
Image
In our case we will be working on the default Windows 7 image that we have copied from Windows 7 DVD, called install.wim. It is located in the [DVD drive]:\sources\ folder, and we will copy it to ourc:\images\ folder. We also have c:\images\mount\ folder which we will use to mount our image. We have also installed The Windows Automated Installation Kit (WAIK) for Windows 7. This is necessary because we need to use the DISM command line tool. So, the first thing we will do is run Deployment Tools Command Prompt with elevated privileges. To do that go to Start > All Programs > Microsoft Windows AIK > Deployment Tools Command Prompt (right-click > Run as administrator).
Mount Image
We have to mount our install.wim image so we can work on it in offline mode. To mount our image we will use the follwing command: dism /mount-wim /wimfile:c:\images\install.wim /index:4 /mountdir:c:\images\mount.
Image 203.1 – Mounting Image
Current Packages
When the mounting is complete, we can see what packages does it currently contain. To do that we will enter the following command (against our mounted image this time): dism /image:c:\images\mount /get-packages.
Image 203.2 – Get-packages Command
The /get-packages option shows us all installed packages on our image. The benefit of using DISM is that we can have an image which we can frequently update so we don’t have to worry about that image becoming out of date. This way, we don’t have to install our image, then apply updates on live machine, and then capture the new image. We can always work on our existing image which saves a lot of precious time.
We can only install packages which are in .cab or .msu format. In our case we will install an update package that we downloaded from Microsoft website. We will put that file in c:\images\packages folder. The update file in our case is Windows6.1-KB2533623-x86.msu.
Image 203.3 – Update File
Adding Packages
To add that package we will enter the following command: dism /image:c:\images\mount /add-package /packagepath:c:\images\packages\Windows6.1-KB2533623-x86.msu. To add packages we use the /add-package option, but we also have to specify the package path with the /packagepathparameter.
Image 203.4 – Adding Package
We can verify that our package is installed by using the dism /image:c:\images\mount /get-packagescommand. Our package will be last on the list because it is the newest installed package. The status isInstall Pending because the actual installation of our package will happen when the image is being applied to the machine.
Unmounting and Saving Changes
Once we are done we can unmount our image, but we have to save our changes with the /commitoption. The whole command is: dism /unmount-wim /mountdir:c:\images\mount /commit.
Image 203.5 – Unmounting
Remember
We can use DISM to service our existing image. This way we will always have updated Windows image. We can install any update or application which is in the Cabinet format (.cab extension) or Microsoft Standalone Update format (.msu).
Commands that are mentioned in this article
- dism /mount-wim /wimfile:c:\images\install.wim /index:4 /mountdir:c:\images\mount – mount install.wim image edition 4, which is located in c:\images\ folder, to the c:\images\mount\ folder
- dism /image:c:\images\mount /get-packages – get all packages contained on mounted image which is located in c:\images\mount folder
- dism /image:c:\images\mount /add-package /packagepath:c:\images\packages\Windows6.1-KB2533623-x86.msu – add Windows6.1-KB2533623-x86.msu package to the mounted image which is located in c:\images\mount folder
- dism /unmount-wim /mountdir:c:\images\mount /commit – unmount image from the c:\images\mount folder and save all changes (commit)
Paths that are mentioned in this article
- [DVD drive]:\sources\install.wim – location of the Windows 7 image on the Windows 7 DVD, which we copied to our Hard Drive
- c:\images\ – folder in which we have copied install.wim image
- c:\images\mount\ – folder which we used to mount install.wim image
- c:\images\packages – folder which we used to save packages before adding them to the mounted image
- Start > All Programs > Microsoft Windows AIK > Deployment Tools Command Prompt – location of the Deployment Tools Command Prompt