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
Switch | Description |
---|
/Get-Help | Displays help for DISM. |
/Get-Wiminfo | Displays information on the images within a .wim file.
dism /get-wiminfo /wimfile:g:\sources \install.wim |
/Get-MountedWiminfo | Displays
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
Switch | Description |
---|
/Mount-Wim | Mounts 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-Wim | Unmounts 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-Wim | Commits 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
Switch | Description |
---|
/Add-Package | Use this to add a package to a mounted image.
Dism /image:C:\mount /Add-Package /PackagePath:C:\packages\package.cab |
/Remove-Package | Use this to remove a cabinet file package from a mounted image.
Dism /image:C:\mount /Remove-Package /PackagePath:C:\packages\package.cab |
/Get-Packages | This will display information about all packages in the mounted image.
Dism /image:C:\mount /Get-Packages |
/Get-Features | This will display a list of features that are enabled in the mounted image.
Dism /Image:C:\mount /Get-Features |
/Get-FeatureInfo | This
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-feature | Features 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-feature | Disabled 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 |
Launch the Deployment Tools Command Prompt with administrative permissions. Select Start => All Programs => Microsoft Windows AIK, right-click the Deployment Tools Command Prompt, and select Run As Administrator. If prompted by User Account Control, click Yes to continue. Determine
the drive letter where your installation DVD is installed. You will
substitute this drive letter for each of the commands instead of the
letter x. View a listing of images in the install.wim file with the following command. Use the drive assigned to your DVD instead of the letter x. dism /get-wiminfo /wimfile:x:\sources\install.wim
Create a directory to which you'll mount the folder with the following command: md c:\mount
Mount the install.wim file in the c:\mount folder with the following command: DISM /mount-wim /wimfile:x:\sources\install.wim /index:1 /mountDir:c:\mount /ReadOnly
If you wanted to modify the image, you would omit the /ReadOnly switch. View details on the mounted image with the following command: DISM /Get-MountedWimInfo
View a list of the packages currently installed on the image with this command: DISM /image:c:\mount /Get-Packages
Once you have mounted an image, you can refer to it using DISM with the /image:path switch. The path is the actual path where it was mounted. In the previous example, it was mounted to the c:\mount directory. Retrieve a list of features available in the mounted image with the following command: DISM /image:c:\mount /Get-features
Disable the games feature within the image with the following command: DISM /image:c:\mount /Disable-feature /FeatureName:InboxGames
Verify that the current state of InboxGames has been changed to disabled with the following command: DISM /image:c:\mount /Get-featureInfo /FeatureName:InboxGames
Unmount the image using the following command: DISM /Unmount-Wim /mountdir:c:\mount /discard
Because the image was
mounted in read-only mode, the changes cannot be committed. However, if
the image was mounted in read/write mode, the /commit switch could be added to commit the changes to the image when it is unmounted.
|