Search
Windows 7

Automating the Deployment of Windows 7 : Imaging with the Windows Automated Installation Kit (part 2) - Understanding the Deployment Image Servicing and Management Tool

Published 5 min readBy Programming4us Editorial Team

2. Understanding the Deployment Image Servicing and Management Tool

The Deployment Image Servicing and Management (DISM) tool is also included in the Windows AIK for Windows 7. The primary benefit of DISM is its ability to modify the contents of an image hosted within a .wim file. This is referred to as offline servicing.

Earlier versions of the Windows AIK required the use of several tools including the Pkgmgr.exe, Intlcfg.exe, and PEimg.exe tools. The DISM tool provides all of the functionality for these tools in a single tool.

DISM is a command-line tool and includes a rich set of switches. If you understand how the ImageX command works with the images as described in the previous section, the DISM tool is easier to grasp. Interestingly, the DISM switches follow the verb-noun format used in Windows PowerShell.

As an example, the get verb is combined with the wiminfo noun in the /get-wiminfo switch. With the verb-noun format, the switches become easy to figure out just by looking at them.

You can access the DISM application via the Deployment Tools Command Prompt by selecting Start => All Programs => Microsoft Windows AIK => Deployment Tools Command Prompt. You'll need administrative permissions when running DISM, so you'll need to right-click the Deployment Tools Command Prompt and select Run As Administrator.

When any of the DISM switches needs to work with a .wim file, it is often specified with the /wimfile switch. The /wimfile switch takes the form of /wimfile:drivePath\filename. For example, an image named image.wim in the C:\images folder would be specified as

/wimfile:c:\images\image.wim

You'll see this used in many commands mentioned in this section. As an example, the /Get-WimInfo switch is used to get information about a .wim file with this full command:

DISM /Get-WimInfo /wimfile:c:\images\image.wim

2.1. Using DISM Get Commands

Many of the get switches are used to retrieve information. Table 1 shows some of the DISM get switches you're likely to use.

Table 1. DISM get switches

SwitchDescription
/Get-HelpDisplays help for DISM.
/Get-WiminfoDisplays information on the images within a .wim file. dism /get-wiminfo /wimfile:g:\sources \install.wim
/Get-MountedWiminfoDisplays information on any images that have been mounted. This includes whether it is in read/write mode and the current status. dism /get-mountedwiminfo

2.2. Using DISM to Mount and Unmount Images

Images must be mounted before you can do any offline servicing. Although you saw earlier that you can use ImageX to mount and unmount images, you can also use DISM.

Table 2 shows some of the commands that can be used to mount, commit, and unmount images.

Table 2. DISM mount switches

SwitchDescription
/Mount-WimMounts an image to a specified directory. The format is Dism /Mount-Wim /WimFile:C:\images\install.wim /index:1 /MountDir:C:\Mount /ReadOnly/ReadOnly switch is omitted to mount the image in read/write mode. The
/Unmount-WimUnmounts the image. The /commit switch is used to write the changes to the image, and the /discard switch does not write the changes. Dism /UnMount-Wim /MountDir:C:\Mount /commit
/Commit-WimCommits the changes to the image but does not unmount the image. Dism /commit Mount-Wim /MountDir:C:\Mount /commit

2.3. Using DISM with Packages and Features

DISM can be used to install, remove, or update Windows packages to an image and manipulate installed features. Packages can be either cabinet (.cab) or Windows Update Stand-alone Installer (.msu) files and are used to distribute software updates, service packs, and language packs.

You can add many common packages to Windows PE images to extend the capabilities of the image depending on what is needed when the PE is booted. These include the following:


WinPE-HTA.cab

This installs HTML application support.


WinPE-Scripting.cab

This adds support for the Windows Scripting Host (WSH), which can be used to execute script files.


WinPE-WMI.cab

This installs support for Windows Management Instrumentation.


WinPE-WDS-Tools.cab

This installs the Windows Deployment Services tools package.

When adding packages with DISM, the package names need to match the exact case of the package. For example, WinPE-WDS-Tools.cab will not work if entered as winpe-wds-tools.cab. However, the case doesn't matter for the DISM commands. For example, DISM /GET-HELP is interpreted the same as Dism /Get-Help.


You can also add packages to regular image files (not only the PE image files). For example, drivers and applications can be added as a package to an offline image.

Table 3 shows some of the DISM switches used to add and remove different elements to an image. Each of these switches is executed against a mounted image, so the /image switch must be used within the command.

Table 3. DISM package and feature switches

SwitchDescription
/Add-PackageUse this to add a package to a mounted image. Dism /image:C:\mount /Add-Package /PackagePath:C:\packages\package.cab
/Remove-PackageUse this to remove a cabinet file package from a mounted image. Dism /image:C:\mount /Remove-Package /PackagePath:C:\packages\package.cab
/Get-PackagesThis will display information about all packages in the mounted image. Dism /image:C:\mount /Get-Packages
/Get-FeaturesThis will display a list of features that are enabled in the mounted image. Dism /Image:C:\mount /Get-Features
/Get-FeatureInfoThis will provide details on any specific feature. For example, the following command provides additional details on the installed games. The StateEnabled or Disabled. dism /image:c:\mount /Get-featureinfo /FeatureName:InboxGames property will be
/Disable-featureFeatures can be disabled using the /Disable-feature switch. The /FeatureName needs to be entered as shown in the Get-Features result. The following command will disable the default games on the image. dism /image:c:\mount /Disable-feature /FeatureName:InboxGames
/Enable-featureDisabled features can be enabled using this switch. The following command will enable the default games on the image. dism /image:c:\mount /Enable-feature /FeatureName:InboxGames