Before you start
Objectives: learn which options can you use when servicing existing images using DISM.
Prerequisites: no prerequisites.
Key terms: image, dism, information, driver, wim, imagex, command, offline, options, detailed, edition, commit, manage, mounts
Facts
Image servicing begins by mounting a previously captured image, which makes the contents of the image accessible to be viewed or modified. Mounting an image does not start the operating system in the file. Mounting an image as read-only lets us view the image, but not make changes. To save changes made to a mounted image back to the original image, we must commit the changes before dismounting the image. An online image is the operating system currently running on a computer; whereas, an offline image is a WIM file.
DISM Tool
Imagine how much time would it take us to deploy the the existing image to the computer, make necessary changes and recapture the new image… To overcome this problem we need a method to update and service our images offline and without booting them up. Windows 7 introduces aDeployment Image Servicing and Management (DISM) tool. DISM is a command line tool which is used to manage existing Windows images. DISM is part of the Windows Automated Installation Kit(Windows AIK). We can use DISM to install updates, drivers and language packs, to enable or disable Windows features, to perform intra-edition upgrades, and to customize international settings. With DSIM we can service different platform types, such as 32bit and 64bit. That means that we can service a 64bit image on a 32bit computer. In addition to servicing offline images, the DISM tool can work with the installation image that s currently online (running Windows). When we work with an online image, we generally gather information rather then make changes to the image. Any option used on the online image can be used with the offline image as well. However, not all ‘get’ options are available on the online image (for example, get-apps). If we run get-apps on the offline image, we will get info on all MSI applications on the image. With this tool we can only service existing system images. We can not capture a new image. DISM is backwards compatible with older tools in the Windows Vista Automated Installation Toolkit. Additionally, DISM works with limited functionality on a Windows Vista SP1 image.
Mounting Images
Before we can service existing image with DISM, we have to mount or apply the image. The DISM/mount-wim option mounts the wim file to the directory specified by the mount directory option. If there is more than one image in the wim file we can use the index option to specify which one we want to mount. We can also mount an image as read-only by using the /readonly parameter.
In addition to using DISM, we can use ImageX to mount and unmount images as well. We can use the /mount option with ImageX to mount image in read-only format to a specified folder. If our wim file has more than one image we can use the index number of the image to mount that specific image. If we also want to be able to write to that image we can mount our image using the /mountrw option. Once we have mounted our image using ImageX and we’re done working with it, we can use the /unmount option which will unmount the image from the specified folder. We can also use the /info option to display information of our wim file with the use of ImageX. With the use of ImageX and DISM we can take our existing images and update, manipulate and continue to maintain them without the need of re-creating new images from scratch.
We have a separate article which describes mounting images using ImageX or DISM tool in detail: Mount and Unmount Windows 7 Image Using ImageX and DISM.
Drivers
We can gather information on existing drivers on the image. We can also add new drivers or remove existing ones. DISM can only manage drivers in a form of INF files. DISM does not support drivers in the form of MSI packages or EXE files. It is recommended to place our drivers in a convenient location and properly name the folders to easier identify them.
DISM has the capability to add a single driver using the /add-driver parameter, and by specifying exact file name. We can also add multiple drivers by specifying the folder in which they are located. We can also add all drivers in subfolders of the parent folder if we use the /recurse parameter. If we want to add drivers that are unsigned, we can use the /forceunsigned option.
DISM can only remove third-party drivers. We can not remove default built-in drivers in a Windows 7 image. All third party drivers are renamed in a form of OEM[number].inf, for example OEM11.inf. We can use the /get-drivers option to find the driver we are looking for and then remove it using the/remove-driver option.
Apps
With DISM we can gather information about Windows Installer or MSI applications, and application patches (MSP files). We can only gather this information from an offline image. Online image does not support application servicing. We can use the /get-apppatches option to list of the application patches in MSI installations that are available in our image. We can also use the GUID of the application to display information relevant to only that specific application. The /check-apppatch parameter will show us specific information about the MSP patches installed in the offline image. We would use the /patchlocation to specify the path of the MSP patch to gather information about specific MSP file. To gather information about all MSP patches installed on our image we can use the /get-apppatchinfoparameter. Using the /get-appinfo and the /productcode parameter we can gather detailed information about a specific MSI application installed on the image. If the /productcode option is not used, the /get-appinfo returns detailed information about all MSI applications. The /get-apps parameter displays all MSI applications installed on the image as well as the GUID for each of them. Then we can take advantage of the GUID option to check specific information when using other parameters.
Have in mind that /get-apppatches and /get-apppatchinfo options only work for MSP patches. The/get-appinfo and the /get-apps options only work for MSI installations. DISM can not be used to obtain information from EXE, DLL or batch files. Additionally, DISM tool can not be used to apply and install patches or MSI applications to an offline image. The Microsoft Deployment Toolkit (MDT 2010) can be used instead to install applications to an offline image.
Patches
In addition to adding drivers and gathering information about installed applications, DISM can be used to apply operating system packages and patches. One of the greatest challenges when working with images is to keep our images updated with the latest security and operating system patches. The most straight forward way to accomplish this is to boot the image, visit Microsoft updates, install necessary patches and recapture the image. This method is time-consuming and requires that we ‘sysprep‘ the system again. The easiest way to update our images is to use DISM. The DISM package servicing options can be used with the mounted offline image to add, remove or update windows packages provided in the cabinet (CAB) files. We can also use the package servicing options to install, update or remove Windows update stand-alone installers or MSU files.
Features
DISM can also be used to enable or disable Windows features on both offline mounted images and online Windows installations. Have in mind that DISM commands are not case-sensitive, however, feature or patch names are case-sensitive.
For example, the /get-packages command will display basic information about all packages on the mounted image. We can also use the /add-package parameter to install packages on to the system. The package must be in a form of MSU file. We can use the /remove-package option to remove existing package from the image. The /get-featureinfo and /enable-feature option can be used to gather information about installed features on the image, and then enable feature on that image as well. We can use /disable-feature to remove feature from the image.
International Settings
We can use the /get-intl which returns information about the international settings and languages on an online image. This is the only option which can be used on the online image. We can also use other parameters such as /set-timezone to change the time zone on offline image.
Editions
Using DISM we can list editions that are stored on an image. We can also change the current edition to a higher edition. When we perform an intra-edition upgrade to an offline image, we do not require product key. We can use options such as /get-currentedition, /set-edition or /set-productkey to perform intra-edition upgrade.
WindowsPE
In addition to the servicing options mentioned, we can also use DISM to service WindowsPE image. DISM enables us to prepare WindowsPE image, list packages or even enable logging. We also have the ability to associate the Unattended.XML answer file to the mounted image.
Committing Changes
After making changes to the mounted image, we must commit the changes so that they are saved to the mount directory before dismounting the image. We can use the /commit-wim parameter to commit the changes to the folder.
Other DISM Options
The /remount-wim option will remount the image if the mount directory is lost or orphaned. The/cleanup-wim option cleans up any previously used mounts. If we mount and dismount a lot of images on a daily basis we might want to run the cleanup option since we may receive errors from leftover resources from the previous mounts.
The /get-wiminfo option displays information about the images within a win file. If we use the index option, it will return information about the specific image specified by the index number.
Completion
After completing our work with the mounted image, we have to commit the changes and use the/unmount-wim parameter to dismount and close the image file. To commit changes we can use the/commit-wim parameter, or use the /unmount-wim together with /commit parameter. This way the changes are saved.
Advanced DISM Options – Quick Reference
DISM command options that are frequently used are:
- /wimfile – specifies the location of the WIM file
- /mountdir – specifies the local directory in which to mount the WIM file
- /index – specifies the edition if there is more than one edition within a WIM file
- /readonly – mounts the WIM file as read only
- /commit-wim – saves the changes to the WIM file
- /remount-wim – remounts the WIM file if the mount directory is lost or orphaned
- /cleanup-wim – cleans up any previously used resources from the previous mounts
- /get-wiminfo – displays information about the editions within a WIM file
- /get-mountedwiminfo – lists all the currently-mounted images and information about each image, such as the mounted path, index, location and read/write permissions
- /unmount-wim – dismounts the WIM file
- /unmount-wim /discard – reverts all changes made since the last changes were committed and dismounts the WIM file
- /apply-unattend – applies an unattended answer file to an image
We can use the following DISM command options to manage the system image drivers:
- /add-driver – adds the driver to the specified image
- /add-driver /driver – adds all of the drivers in the directory
- /add-driver /driver /recurse – adds all of the drivers in the directory and its subdirectories
- /get-drivers – displays basic information about all out-of-box drivers
- /get-drivers /all – displays basic information about all drivers, in addition to the all out-of-box drivers
- /get-driverinfo – displays detailed information about a specific driver package
- /remove-driver – removes third-party drivers
- /forceunsigned – overrides the digital signature requirements for drivers on 64-bit versions of Windows 7
The driver path must use the driver’s published name. Use /get-drivers /all to view the published name. We cannot remove default drivers. Place your drivers in a convenient location before using DISM to update the system image drivers. DISM does not support drivers in the form of .msi packages or .exe files. If adding multiple drivers in the same command, the drivers are installed in the order that they are listed in the command.
We can use the following DISM command options to manage Windows applications (.msi) and application patches (.msp files):
- /get-apppatches – displays a list of MSP files that are available on the image
- /check-apppatch /patchlocation – displays information only if the MSP patches are applicable to the offline image
- /get-apppatchinfo – displays detailed information about all installed MSP patches
- /get-appinfo – displays detailed information for all the installed MSI applications
- /get-appinfo/productcode – displays detailed information about the specific MSI application installed on the image
- /get-apps – displays all MSI applications installed on the offline image as well as the GUID
DISM does not retrieve information from .exe or .dll files. The DISM command does not have an /add-apps option to install applications; use Microsoft Deployment toolkit to install applications to a previously-captured offline image.
We can use the following dism command options to manage Windows packages provided in a cabinet (.cab) or Windows Update Stand-alone Installer (.msu) file format:
- /get-packages – displays basic information about all the packages that have been installed on the image
- /get-packageinfo /packagename – displays detailed information about a specific .cab package
- /get-packageinfo /packagepath – displays detailed information about a specific package
- /add-package /packagepath – installs a specific .cab or .msu package to the image, including: a single .cab or .msu file, a folder containing a single expanded .cab file, a folder containing a single .msu file and a folder containing multiple .cab or .msu files
- /remove-package – removes a .cab installed package
- /get-features – displays information about all the features in a package
- /get-featureinfo – displays detailed information about the feature
- /enable-feature – enables a specific feature on the image
- /disable-feature – disables a specific feature on the image
DISM commands are not case-sensitive; however, feature names are case-sensitive. We cannot remove .msu installations.
We can use the following DISM command options to manage international settings for an offline or online image:
- /get-intl – returns information about the international settings and languages on an online image
- /set-uilang – installs a new language on the image
- /set-inputlocale – adds a new keyboard layout to the image
- /set-timezone – changes the time zone of the mounted offline image
The Windows 7 installation media has a pre-staged package for each Windows 7 edition. This is referred to as an edition-family image. We can use the following DISM command options to manage and configure the Windows editions on an offline or online image:
- /get-currentedition – identifies the edition of the offline or online image
- /set-edition – upgrades the Windows image to a higher edition
- /set-productkey – enters the product key for the current edition in an offline Windows image after you change an offline Windows image to a higher edition.
The following options revert all pending actions from the previous servicing operations because the actions might be the cause of a boot failure:
- /cleanup-image
- /revertpendingactions
ImageX Quick Reference
ImageX is primarily used to capture a Windows 7 installation onto a network share, but it can also mount an image so that it can be modified. After the image is modified, we can use ImageX to capture the image, append the image to a WIM file, or export the image as a separate file. If we do not need to capture, append, or export the image after we modify it, we should use DISM to mount the image instead of using ImageX.
Common ImageX command options are:
- /mount – mounts a Read-Only version of the image file to the specified directory
- /mountrw – mounts a Read-Write version of the image file
- /unmount – dismounts the image file
- /commit – saves the changes to the image while dismounting
- /info – displays detailed information about the image file
- /export – deletes unnecessary resources from the image file, reducing its size
- /append – appends files to the image. Appended image files must use the same compression type as the initial capture
Examples
We have an article on how to service existing images and on how to apply updates to existing image, so be sure to check them out if you want to see a demo on how to work with images using DISM.
Remember
We can use DISM tool to update and service existing images, without booting them up. Before we can service existing image with DISM, we have to mount or apply the image. After making changes to the mounted image, we must commit the changes so that they are saved to the mount directory before dismounting the image. DISM commands are not case-sensitive.