A virtual hard disk (VHD) with an applied Windows® 7 image can be serviced offline or serviced online with command-line tools such as Deployment Image Servicing and Management (DISM.exe). For more information about creating a VHD and applying a Windows 7 image, see Walkthrough: Deploy a Virtual Hard Disk for Native Boot.

Note:

DISM operations performed on a VHD cannot be discarded by using the /unmount option, as they can with .wim files. It is recommended that you create a backup copy of the .vhd file before servicing it.

Terms

attach

You can map the contents of a Windows 7 image in a VHD to a directory by attaching a vdisk using the Windows 7 DiskPart tool. Mapping the contents of an image to a directory is similar to mounting the image. The Attach vdisk command adds the .vhd file as a disk to the storage controller on the host.

offline

Offline servicing occurs when you modify or service a Windows® image entirely offline without booting it first.

vdisk

A virtual disk, as referred to in the DiskPart tool.

Step 1: Prepare an offline VHD

  1. To prepare the VHD for servicing with the DISM tool, attach the vdisk using the DiskPart tool. At an elevated command prompt, type:

    diskpart
    select vdisk file=c:\windows7.vhd
    attach vdisk
    assign letter=v
    exit
    
    The VHD appears as a lettered drive, such as V:\, on the computer.

Step 2: Service the VHD using DISM

Use the DISM tool to modify or service the Windows image entirely offline. For more information about the DISM tool, see Deployment Image Servicing and Management Technical Reference.

  1. Open an elevated command prompt. Click Start, click All Programs, click Accessories, right-click Command Prompt, select Run as administrator.

  2. Navigate to the DISM tool. For example, type:

    cd /d C:\Program Files\<version>\Tools\Servicing
    
    Where <version> can be Windows OPK or Windows AIK.

Note:

In the following examples, the drive letter V:\ is used to represent the attached vdisk.

The following actions can be performed on the attached vdisk using the DISM tool:

You can also Use an answer file to service an offline VHD to perform most of these functions.

Add drivers

  1. At the command prompt, type the following command to add a specific driver to the image:

    Dism /image:V:\ /Add-Driver /driver:C:\drivers\mydriver.INF
    
  2. Multiple drivers can be also added with one set of commands, if you specify a folder instead of an .inf file. To install all the drivers in a folder and all its subfolders, use the /recurse option. For example, at the command prompt, type:

    Dism /image:V:\ /Add-Driver /driver:C:\drivers /recurse
    
    To install an unsigned driver, use the /ForceUnsigned option to override the requirement that drivers installed on X64-based computers must have a digital signature. For example, at the command prompt, type:

    Dism /image:V:\ /Add-Driver /driver:C:\drivers\mydriver.INF /ForceUnsigned
    
  3. Optional: You can confirm that the drivers were added to the image by using the /Get-Drivers option. For example, type the following at the command prompt:

    Dism /image:V:\ /Get-Drivers
    

Remove drivers

  1. Multiple drivers can be removed on one command line using the /Remove-Driver and /driver options. For example, at the command prompt, type:

    Dism /image:V:\/Remove-Driver /driver:OEM1.inf /driver:OEM2.inf
    
    Caution:

    Removing a boot-critical driver package can make the offline Windows image unable to boot. In addition, you cannot remove in-box drivers, which are drivers that are installed on Windows by default. For more information, see Driver Servicing Command-Line Options.

Add a package or language pack

  1. You can add multiple packages on one command line using the /Add-Package and /PackagePath options. For example, at the command prompt, type:

    Dism /image:V:\ /Add-Package /PackagePath:C:\packages\package1.cab /PackagePath:C:\packages\package2.cab
    
  2. After you add or remove a language pack in a Windows image, you can set the default user-interface (UI) language, which is also known as the display language. At the same time, you can configure the international settings in the Windows image using DISM.

    To change all international language settings in the mounted offline image to match the default values set by Microsoft for a given language, at the command prompt, type:

    Dism /image:V:\/Set-SKUIntlDefaults:en-us
    
    For more information about default values, see Language Pack Default Values

    Optionally, you can configure different values for different settings, including UI language, system locale, user locale, input locale, and others. For more information about specifying individual values for each of these settings, see Languages and International Servicing Command-Line Options.

Remove a package or language pack

Important:

You should not remove a language pack from a mounted offline Windows image if there are pending online actions. To that end, the Windows image you are using should be a recently installed and captured image. This will ensure that the Windows image does not have any pending online actions that require a reboot.

  1. Optional: Use the /Get-Intl command-line option to list the languages in the offline image:

    Dism /image:V:\ /Get-Intl
    
  2. You can remove multiple .cab files using one command-line statement, using the /Remove-Package and /PackagePath options. For example, at the command prompt, type:

    Dism /image:V:\ /Remove-Package /PackagePath:C:\packages\package1.cab /PackagePath:C:\packages\package2.cab
    
  3. After you add or remove a language pack in a Windows image, you can set the default user-interface (UI) language, which is also known as the display language. At the same time, you can configure the international settings in the Windows image using DISM.

    To change all international language settings in the mounted offline image to match the default values set by Microsoft for a given language, at the command prompt, type:

    Dism /image:V:\ /Set-SKUIntlDefaults:en-us
    
    For more information about default values, see Language Pack Default Values

    Optionally, you can configure different values for different settings, including UI language, system locale, user locale, input locale, and others. For more information about specifying individual values for each of these settings, see Languages and International Servicing Command-Line Options.

Add a local pack

Local packs provide region-specific customizations, such as Windows® Internet Explorer® Favorites and RSS feeds, for a Windows 7 installation. For more information, see Add and Remove Local Packs.

  1. You can add multiple packages using the /Add-Package and /PackagePath options. For example, at the command prompt, type:

    Dism /image:V:\ /Add-Package /PackagePath:"C:\Local Packs\Windows-LocalPack-DE-Package.cab" /PackgagePath:"C:\Local Packs\Windows-LocalPack-AU-Package.cab"
    
  2. Optional: You can confirm that the packages were added to the image using the /Get-Packages option. For example, type the following at the command prompt:

    Dism /image:V:\ /Get-Packages
    

Before the content of a local pack will appear on a Windows installation, the location (GeoID) of the current user must be set to a location that matches the target location for that local pack. For more information, see Add and Remove Local Packs

Remove a local pack

  1. Type the following command to list the packages in the image:

    Dism /image:V:\ /Get-Packages 
    
    Review the packages to find the package that you want to disable.

  2. You can remove multiple packages on one command line. For example, at the command prompt, type:

    Dism /image:V:\ /Remove-Package /PackageName:"Microsoft-Windows-localPack-DE-package~31bf3856ad364e35~x86~~6.1.6913.0"
    
    Important:

    The above commands are examples only. The build numbers will be different for your packages.

Before the content of a local pack will appear on a Windows installation, the location (GeoID) of the current user must be set to a location that matches the target location for that local pack. For more information, see Add and Remove Local Packs

Enable or disable a Windows feature

  1. Optional: Use the /Get-Features option to list all the features available in the operating system. For example, at the command prompt, type:

    Dism /image:V:\ /Get-Features
    
    Review the features to find the feature that you want to enable.

  2. Optional: Use the /Get-FeatureInfo and /FeatureName options to list information about the specific feature you are interested in. For example, at a command prompt, type:

    Dism /image:V:\ /Get-FeatureInfo /FeatureName:Hearts
    
  3. Use the /Enable-Feature and /FeatureName options to enable a specific feature in the image. For example, at a command prompt, type:

    Dism /image:V:\ /Enable-Feature /FeatureName:Hearts
    
  4. Use the /Disable-Feature and /FeatureName options to disable a specific feature in the image. For example, at a command prompt, type:

    Dism /image:V:\ /Disable-Feature /FeatureName:Hearts
    

Change the Windows image to a higher edition

  1. Use the /Get-CurrentEdition command to find the edition of Windows your image is currently set to. For example, at a command prompt, type:

    Dism /image:V:\ /Get-CurrentEdition
    
    Note which edition of Windows your image is currently set to. If the image has already been changed to a higher edition, you should not change it a second time. We recommend using the lowest edition as a starting point.

  2. Use the /Get-TargetEditions option to find the editions of Windows that you can change your image to. For example, at a command prompt, type:

    Dism /image:V:\ /Get-TargetEditions
    
    Note the edition ID for the edition you want to change to.

    Note:

    You cannot set a Windows image to a lower edition. Lower editions will not appear when you use the /Get-TargetEditions option.

  3. Use the /Set-Edition option to specifying the edition ID to change the Windows image. For example, at a command prompt, type:

    Dism /image:V:\ /Set-Edition:Ultimate
    

Use an answer file to service an offline VHD

For more information about creating an answer file for servicing offline images, including the components used to remove drivers, enumerate drivers and packages, and modify configuration settings, see the Service an Offline Image section of the documentation.

  1. Use DISM to apply the unattended installation answer file to the Windows image on the attached vdisk. For example, at the command prompt, type:

    DISM /image:V:\ /Apply-Unattend:C:\test\answerfiles\myunattend.xml
    
    For more information about applying an unattended answer file, see Unattended Servicing Command-Line Options.

Step 3: Detach the VHD

When you have finished modifying or servicing the Windows 7 image on the VHD, use the DiskPart tool to detach the vdisk again.

At the command prompt, type:

diskpart
select vdisk file=c:\windows7.vhd
detach vdisk
exit

Service an Online VHD

To service a VHD online, you must boot into the Windows installation on the VHD. For more information about booting a VHD, see Walkthrough: Deploy a Virtual Hard Disk for Native Boot. You can then follow the steps in the Service an Online Image section of the documentation to modify or service the VHD as you would any other installation of Windows 7.

See Also