Windows 7 / Getting Started

Customizing Images Using Deployment Image Servicing and Management

The Deployment Image Servicing and Management (DISM) tool is included with the WAIK and can be used to perform offline maintenance of images. Offline maintenance means that you don't need to boot into the image to make changes, but can instead modify the contents of an image file that is stored within a WIM file. You can apply this modified image to a system with the changes. For example, if you followed the previous procedures using ImageX to capture an image, you can now use DISM to modify the contents of the image without having to apply the image to a system and booting into the system. Additionally, you don't have to recapture the image. If you use DISM to open the image in read/write mode, you can save the changes with DISM.

The steps for modifying an image with DISM are as follows:

  1. Mount the image using DISM. This expands the image into a folder on your hard drive. All the files and folders that are stored on the original hard drive of the captured image are accessible here.
  2. Modify the image. You can do so using DISM. DISM allows you to add and remove drivers, packages, and features. Additionally, you can copy files and folders directly into the mounted image.
  3. After completing the modifications, commit the image. This step rewrites the image file with your changes.
Uppercase or Lowercase?
DISM is not case sensitive, but options are case sensitive. When entering DISM commands, you can usually enter them as all uppercase, all lowercase, or a combination of the two. It's common to show the documentation with initial caps for words, but this is just for readability. For example, the following three commands are interpreted the same by DISM:
DISM /Get-WimInfo /WimFile:C:\Images\Install.wim
dism /get-wiminfo /wimfile:c:\images\install.wim
DISM /GET-WIMINFO /WIMFILE:C:\IMAGES\INSTALL.WIM
However, there are some exceptions. For example, when working with features in an offline image, you need to use the exact case of the feature such as InboxGames, instead of inboxgames, or Solitaire instead of solitaire. If you don't follow the exact case of the feature, the command won't be recognized.

While this section covers many of the basic capabilities of DISM, there is much more you may want to dig into. You can open the Windows Automated Installation Kit (WAIK) Users Guide for Windows 7, which is installed when you install the WAIK, and take a look at the following help articles for additional information:

  • Deployment Image Servicing and Management Command-Line Options
  • Driver Servicing Command-Line Options
  • Operating System Package Servicing Command-Line Options

The easiest way to locate these articles is to select the Search tab, enter the article title in the search text box, select the Search Titles check box in the lower-left corner, and click List Topics.

Viewing Information about an Image with DISM

When using DISM, you'll frequently use the /WimFile switch. This points to the image file with the full path in the following format:

/WimFile:Drive:FullPath\ImageName.wim

For example, if an image file named install.wim is stored in the Images folder on the C: drive, it would take the following format. Notice that there are no spaces anywhere in this switch:

/WimFile:C:\Images\Install.wim

The following example shows the /WimFile switch used with the /Get-WimInfo switch to retrieve information on an image file. In this example, the install.wim file from the \sources folder of the Windows 7 installation DVD is copied into the C:\Images folder.

DISM /Get-WimInfo /WimFile:C:\Images\Install.wim

Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Details for image : C:\Images\Install.wim

Index : 1
Name : Windows 7 STARTER
Description : Windows 7 STARTER
Size : 7,936,340,784 bytes

Index : 2
Name : Windows 7 HOMEBASIC
Description : Windows 7 HOMEBASIC
Size : 7,992,394,907 bytes

Index : 3
Name : Windows 7 HOMEPREMIUM
Description : Windows 7 HOMEPREMIUM
Size : 8,432,859,356 bytes

Index : 4
Name : Windows 7 PROFESSIONAL
Description : Windows 7 PROFESSIONAL
Size : 8,313,318,889 bytes

Index : 5
Name : Windows 7 ULTIMATE
Description : Windows 7 ULTIMATE
Size : 8,471,060,645 bytes

The operation completed successfully.

This output is a lot easier to digest than the ImageX XML output shown earlier. It's interesting to note that the queried install.wim file is about 2.2 GB when stored on a disk. However, it holds the contents of these five installation images, and each of the images will expand to about 8 GB.

All image files don't include multiple images. For example, if you captured the image using ImageX earlier, the Win7.wim file would have only one image with a name of Mastering Windows 7. If you copied that image to the Images folder on your computer, you could use the following command to view its details:

DISM /Get-WimInfo /WimFile:C:\Images\win7.wim

Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Details for image : C:\Images\win7.wim

Index : 1
Name : Mastering Windows 7
Description : <undefined>
Size : 9,759,693,132 bytes

The operation completed successfully.

Mounting an Image

The /Get-WimInfo is useful for viewing details about images in a WIM file, but it doesn't allow you to work with an image or view the actual contents. To work with the contents, you need to mount the image using the /Mount-Wim switch.

For example, you can use the following command to mount an image:

dism /mount-wim /wimfile:c:\images\win7.wim /index:1 /MountDir:C:\MountWin7

Deployment Image Servicing and Management tool

Version: 6.1.7600.16385
Mounting image
[==========================100.0%==========================]
The operation completed successfully.

This command uses the familiar /wimfile switch and also the /index and /MountDir switches. These switches, and some additional switches available with /Mount-wim, are explained in Table below. Mounting an image will take some time but will show you progress as it expands the files. The directory where you'll mount the image must exist before you execute the command. You can create the directory using Windows Explorer or from the command prompt with this command:

md c:\MountWin7

Table: DISM /Mount-Wim options

SwitchDescriptionExample
/WimFileIdentifies the path of the image.wim file./WimFile:C:\Images\Install.wim
/IndexIdentifies the image index number of the image to mount./WimFile:C:\Images\Install.wim /index:1
/Name:Identifies the image with the name instead of the index number. If there are spaces in the name, it must be enclosed in quotes./WimFile:C:\Images\Install.wim /name:"Windows 7 Ultimate"
/MountDirIdentifies the location where the image file will be mounted and expanded as individual files./MountDir:Path
/ReadOnlySpecifies that the image will be in read-only mode and can't be committed. If not used, the command can be committed./ReadOnly

After you mount the image, you can use Windows Explorer to view the contents of the image.

At this point, you can copy any files you want to the mounted image. Additionally, you can use DISM to service drivers and applications on the image.

Servicing Drivers in an Image

DISM includes several commands you can use to view, add, and remove drivers within an image. These drivers must use the INF file format. Unfortunately, drivers that are installed as executable files are not supported using these methods.

You can use the following command to view any third-party drivers that are already included in an image:

dism /image:c:\MountWin7 /get-drivers

Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Image Version: 6.1.7600.16385

Obtaining list of 3rd party drivers from the driver store...

Driver packages listing:

Published Name : oem0.inf
Original File Name : prnms001.inf
Inbox : No
Class Name : Printer
Provider Name : Microsoft
Date : 6/21/2006
Version : 6.1.7600.16385

The operation completed successfully.

Table: shows several other available DISM commands

SwitchDescriptionExample
/Get-DriverInfoDisplays detailed information about a specific driver package. The package is specified using the Published Name obtained from the /get-drivers command.dism /image:c:\mountwin7/get-driverinfo /driver:oem0. inf
/Add-DriverAdds a third-party driver package to an offline image. The example shows how to add a driver package that has been copied to a folder named Display. DISM scans the folder and installs all the drivers in the folder.dism /image:c:\mountwin7 /adddriver /driver:c:\display
/Remove-DriverRemoves a third-party driver from an offline image. You can use the Published Name of the driver displayed with /Get-Drivers.dism /image:c:\mountwin7/remove-driver /driver:oem9.inf

Servicing the Operating System in an Image

You can add and remove features and packages from an image. Packages come as cabinet (.cab) files or Microsoft Windows Update Standalone Installer (.msu) files. Table below shows common commands you can use to work on packages and features with an offline image.

Table: DISM operating system command-line options

SwitchDescriptionExample
/Get-PackagesDisplays information about installed packages.dism /image:c:\mountwin7 /get-packages
/Get-PackageInfoDisplays detailed information on a specific package. You can identify the package using the Package Identity label displayed with the /Get-Packages command.dism /image:c:\mountwin7 /get-packageinfo /PackageName:<package identity> dism /image:c:\mountwin7 /get-packageinfo /PackageName:Microsoft-Windows-LocalPack-ZAPackage~ 31bf3856ad364e35~x86~~6.1.7600.16385
/Add-PackageAdds a package to the offline image. You can use this switch to add any CAB or MSU file to the image. The example adds the KB 958559 package to install Windows Virtual PC used for Windows XP Mode.
/Remove-PackageRemoves installed cabinet (.cab) packages. Updates (.msu packages) can't be removed this way. You can identify the package using the Package Identity displayed with the /Get-Packages command.dism /image:c:\mountwin7 /remove-package PackageName:<package identity>~LBdism / image:c:\mountwin7 /remove-package / PackageName:Microsoft-Windows-LocalPack-ZAPackage~ 31bf3856ad364e35~x86~~6.1.7600.16385

When you boot into Windows 7, you can enable and disable installed features via the Control Panel. Figure below shows the Windows Features dialog box. You can access this by selecting Control Panel → Programs → Turn Windows Features On Or Off.

Turning Windows features on or off

You can also manipulate these features in an offline image using DISM. Table below shows some of the available commands. This is one of the few times when using uppercase and lowercase matters at the command prompt. Specifically, the features must be entered exactly as shown in the /Get-Features output.

Table: DISM features' command-line options

SwitchDescriptionExample
/Get-FeaturesDisplays a list of available features within the image. It also shows whether the feature is enabled or disabled.dism /image:c:\mountwin7 / get-features
/Get-FeatureInfoProvides detailed information on a feature. Note that features must be entered using exact case as shown in the /Get-Features output. If you enter Chess as chess, it will not be recognized.dism /image:c:\mountwin7 /get-featureinfo/ featurename:Chess
/Enable-FeatureEnables a feature using the feature name. The feature name must be entered using exact case as shown in the /Get-Features output.dism /image:c:\mountwin7 /enable-feature /featurename:Chess
/Disable-FeatureDisables a feature using the feature name. The feature name must be entered using exact case as shown in the /Get-Features output.dism /image:c:\mountwin7 /disable-feature /featurename:Chess

Committing an Image

Committing an image applies all the changes you've made to the mounted image to the original WIM file. For example, if you mounted an image from the win7.wim file into the C:\mountwin7 folder, you can use the following command to commit the changes:

dism /unmount-wim /Mountdir:c:\MountWin7 /commit
Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Saving image
[==========================100.0%==========================]
Unmounting image
[==========================100.0%==========================]
The operation completed successfully.

The /unmount switch also removes the files within the mounted folder. In other words, if the image was mounted to the C:\MountWin7 folder, after unmounting it all of the files within this folder will be deleted. If you decide you don't want to save the changes, you can unmount the image with the /discard switch instead of the /commit switch as follows:

dism /unmount-wim /Mountdir:c:\MountWin7 /discard

DISM will not dedicate system resources to unmounted images. However, if you don't unmount an image, DISM continues to track the image even through reboots of your system. It's best to unmount the image when you're done with it. You can verify that you don't have any mounted images with the following command:

dism /get-mountedwiminfo

Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Mounted images:

No mounted images found.

The operation completed successfully.

Ideally, it will show No mounted images found. If it identifies mounted images you aren't working with, you should investigate them and unmount them if they aren't needed.

[Previous] [Contents] [Next]