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
- 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
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.
- Open an elevated command prompt. Click Start, click
All Programs, click Accessories, right-click
Command Prompt, select Run as administrator.
- Navigate to the DISM tool. For example, type:
cd /d C:\Program Files\<version>\Tools\Servicing
Note: | |
In the following examples, the drive letter |
The following actions can be performed on the attached vdisk using the DISM tool:
- Add drivers
- Remove drivers
- Add a package or language
pack
- Remove a package or language
pack
- Add a local pack
- Remove a local pack
- Enable or Disable a Windows
feature
- Change the Windows image to a
higher edition
You can also Use an answer file to service an offline VHD to perform most of these functions.
Add drivers
- 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
- 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
Dism /image:V:\ /Add-Driver /driver:C:\drivers\mydriver.INF /ForceUnsigned
- 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
- 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
- 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
- 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
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. |
- Optional: Use the /Get-Intl command-line option to list
the languages in the offline image:
Dism /image:V:\ /Get-Intl
- 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
- 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
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.
- 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"
- 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
- Type the following command to list the packages in the
image:
Dism /image:V:\ /Get-Packages
- 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
- 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
- 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
- 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
- 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
- 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
- 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: You cannot set a Windows image to a lower edition. Lower editions will not appear when you use the /Get-TargetEditions option.
- 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.
- 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
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.