了解 DISM
DISM.exe 是一个默认在Windows 7 操作系统里的新的命令行工具,而且还作为 Windows 自动安装工具包 (Windows AIK) 2.0 版的一部分的默认安装中。
您可以使用DISM工具来管理Windows 映像(WIM)文件和虚拟硬盘(VHD)文件。DISM.exe主要管理脱机的Windows 映像,其一部分功能也可以管理运行中的Windows 操作系统。 通过管理添加或删除操作系统文件,包括设备驱动程序和语言包等。 DISM 还可用于升级不同版本的 Windows 映像,用于准备Windows PE 映像。
您可以使用DISM工具管理下面版本的Windows:
Windows Vista SP1 或更高版本Windows 2008 ServerWindows 7Windows Server 2008 R2
使用 DISM
在 Windows Vista (或使用 Windows AIK 1.1)管理映象,需要使用几个不同的工具。 例如,让我们说你想要你以前捕获主安装的映像上安装一个预置的设备驱动程序。 为此请在 Vista 中您必须:
- 使用 ImageX 的映像安装
- 添加设备驱动程序使用程序包管理器 (Pkgmgr.exe)
- 卸载映像使用 ImageX
此外,如果您的图像是一个 Windows PE 映像然后还需要使用 Windows 预安装环境 (PEimg.exe) 工具来准备图像。 最后,如果需要修改语言和找到的图像设置您要与使用国际设置配置工具 (Intlcfg.exe)。
不过从Windows 7开始,现在DISM.exe 替换了早期的1.1版本的Windows AIK 中Pkgmgr.exe、Intlcfg.exe 和PEimg.exe 工具。 此外,DISM 还包括安装和卸载映像。
DISM 的典型用途可能是将设备驱动程序添加到 Windows 离线映像,让我们做一下这种情况下,了解如何使用DISM。
第一,在安装了Windows AIK 2.0的计算机上新建一个C:\Images的文件夹,用于存放install.wim文件。
C:\Program Files\Windows AIK\Tools\PETools>dir C:\Images
Volume in drive C has no label.
Volume Serial Number is 1C9A-D699
Directory of C:\Images
05/03/2009 12:46 PM <DIR> .
05/03/2009 12:46 PM <DIR> ..
04/22/2009 07:28 AM 2,218,242,699 install.wim
1 File(s) 2,218,242,699 bytes
2 Dir(s) 180,411,486,208 bytes free
注:
接下来,C:\Drivers 文件夹中是在 Windows 7 beta 版 2.91 Microsoft LifeCam 硬件的驱动程序:
接下来,C:\Drivers 文件夹中是在 Windows 7 beta 版 2.91 Microsoft LifeCam 硬件的驱动程序:
C:\Program Files\Windows AIK\Tools\PETools>dir C:\Drivers
Volume in drive C has no label.
Volume Serial Number is 1C9A-D699
Directory of C:\Drivers
05/03/2009 01:19 PM <DIR> .
05/03/2009 01:19 PM <DIR> ..
05/03/2009 01:19 PM <DIR> VX6000
0 File(s) 0 bytes
3 Dir(s) 180,411,486,208 bytes free
我们将会新建一个空的文件夹,C:\Servicing。让我们开始使用DISM.exe 命令在install.wim 文件中,用/
get-wiminfo 参数来显示所有Windows 映像的列表。请记住一个安装映像可以包含多个Windows 映像。
C:\Program Files\Windows AIK\Tools\PETools>dism /get-wiminfo /wimfile:C:\Images\install.wim
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Details for p_w_picpath : C:\Images\install.wim
Index : 1
Name : Windows 7 STARTER
Description : Windows 7 STARTER
Size : 7,927,317,234 bytes
Index : 2
Name : Windows 7 HOMEBASIC
Description : Windows 7 HOMEBASIC
Size : 7,983,232,406 bytes
Index : 3
Name : Windows 7 HOMEPREMIUM
Description : Windows 7 HOMEPREMIUM
Size : 8,422,988,972 bytes
Index : 4
Name : Windows 7 PROFESSIONAL
Description : Windows 7 PROFESSIONAL
Size : 8,303,245,818 bytes
Index : 5
Name : Windows 7 ULTIMATE
Description : Windows 7 ULTIMATE
Size : 8,461,373,562 bytes
The operation completed successfully.
我们要部署 Windows 7 Professional ,我们可以看到从上述命令的情况下输出索引号是此特定的图像为4。所以,让我们装载到空的 C:\Servicing 文件夹,使用这个特定的 Windows 映像,使用DISM.exe 命令的
/mount-wim 参数:
C:\Program Files\Windows AIK\Tools\PETools>dism /mount-wim /wimfile:C:\Images\install.wim /index:4 /mountdir:C:\Servicing
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Mounting p_w_picpath
[==========================100.0%==========================]
The operation completed successfully.
我们可以使用
/get-mountedinfo这样的参数来验证是否已成功装入图像:
C:\Program Files\Windows AIK\Tools\PETools>dism /get-mountedwiminfo
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Mounted p_w_picpaths:
Mount Dir : C:\Servicing
Image File : C:\Images\install.wim
Image Index : 4
Mounted Read/Write : Yes
Status : Ok
The operation completed successfully.
如果我们检查 C:\Servicing 目录的内容,我们可以看到文件和目录:
C:\Program Files\Windows AIK\Tools\PETools>dir C:\Servicing
Volume in drive C has no label.
Volume Serial Number is 1C9A-D699
Directory of C:\Servicing
04/22/2009 03:36 AM <DIR> .
04/22/2009 03:36 AM <DIR> ..
03/20/2009 10:42 AM 24 autoexec.bat
03/20/2009 10:42 AM 10 config.sys
04/22/2009 01:17 AM <DIR> PerfLogs
04/22/2009 05:26 AM <DIR> Program Files
04/22/2009 03:27 AM <DIR> Users
04/22/2009 05:29 AM <DIR> Windows
2 File(s) 34 bytes
6 Dir(s) 180,321,382,400 bytes free
现在让我们查看我们可以装入哪些内容,执行什么样的操作:
C:\Program Files\Windows AIK\Tools\PETools>dism /p_w_picpath:C:\Servicing /?
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Image Version: 6.1.7100.0
The following commands may be used to service the p_w_picpath:
WINDOWS EDITION SERVICING COMMANDS:
/Set-ProductKey - Populates the product key into the offline p_w_picpath.
/Get-TargetEditions - Displays a list of Windows editions that an p_w_picpath can be upgraded to.
/Get-CurrentEdition - Displays the editions of the specified p_w_picpath.
/Set-Edition - Upgrades the Windows p_w_picpath to a higher edition.
UNATTEND SERVICING COMMANDS:
/Apply-Unattend - Applies an unattend file to an p_w_picpath.
DRIVER SERVICING COMMANDS:
/Remove-Driver - Removes driver packages from an offline p_w_picpath.
/Add-Driver - Adds driver packages to an offline p_w_picpath.
/Get-DriverInfo - Displays information about a specific driver in an offline p_w_picpath or a running operating system.
/Get-Drivers - Displays information about all drivers in an offline p_w_picpath or a running operating system.
INTERNATIONAL SERVICING COMMANDS:
/Set-LayeredDriver - Sets keyboard layered driver.
/Set-UILang - Sets the default system UI language that is used in the mounted offline p_w_picpath.
/Set-UILangFallback - Sets the fallback default language for the system UI in the mounted offline p_w_picpath.
/Set-UserLocale - Sets the user locale in the mounted offline p_w_picpath.
/Set-SysLocale - Sets the language for non-Unicode programs (also called system locale) and font settings in the mounted offline p_w_picpath.
/Set-InputLocale - Sets the input locales and keyboard layouts to use in the mounted offline p_w_picpath.
/Set-TimeZone - Sets the default time zone in the mounted offline p_w_picpath.
/Set-AllIntl - Sets all international settings in the mounted offline p_w_picpath.
/Set-SKUIntlDefaults - Sets all international settings to the default values for the specified SKU language in the mounted offline p_w_picpath.
/Gen-LangIni - Generates a new lang.ini file.
/Set-SetupUILang - Defines the default language that will be used by setup.
/Get-Intl - Displays information about the international settings and languages.
APPLICATION SERVICING COMMANDS:
/Check-AppPatch - Displays information if the MSP patches are applicable to the mounted p_w_picpath.
/Get-AppPatchInfo - Displays information about installed MSP patches.
/Get-AppPatches - Displays information about all applied MSP patches for all installed applications.
/Get-AppInfo - Displays information about a specific installed MSI application.
/Get-Apps - Displays information about all installed MSI applications.
PACKAGE SERVICING COMMANDS:
/Add-Package - Adds packages to the p_w_picpath.
/Remove-Package - Removes packages from the p_w_picpath.
/Enable-Feature - Enables a specific feature in the p_w_picpath.
/Disable-Feature - Disables a specific feature in the p_w_picpath.
/Get-Packages - Displays information about all packages in the p_w_picpath.
/Get-PackageInfo - Displays information about a specific package.
/Get-Features - Displays information about all features in a package.
/Get-FeatureInfo - Displays information about a specific feature.
/Cleanup-Image - Performs cleanup and recovery operations on the p_w_picpath.
For more information about these servicing commands and their arguments,
specify a command immediately before /?.
Examples:
DISM.exe /Image:C:\test\offline /Apply-Unattend /?
DISM.exe /Image:C:\test\offline /Get-Features /?
DISM.exe /Online /Get-Drivers /?
上述
DRIVER SERVICING COMMANDS下,找到我们想要使用的参数。让我们使用了
/get-drivers参数来显示的安装映像中已安装的驱动程序列表:
C:\Program Files\Windows AIK\Tools\PETools>dism /p_w_picpath:C:\Servicing /get-drivers
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Image Version: 6.1.7100.0
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.7100.0
The operation completed successfully.
现在让我们使用了
/add-driver参数,将我们的LifeCam驱动程序添加到已装入映象:
C:\Program Files\Windows AIK\Tools\PETools>dism /p_w_picpath:C:\Servicing /add-driver /driver:C:\Drivers\VX6000\vx6000.inf
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Image Version: 6.1.7100.0
Found 1 driver package(s) to install.
Installing 1 of 1 - C:\Drivers\VX6000\vx6000.inf: The driver package was successfully installed.
The operation completed successfully.
让我们使用
/get-drivers再次验证LifeCam驱动程序已成功添加到已装入映象:
Deployment Image Servicing and Management tool
Version: 6.1.7100.0Image Version: 6.1.7100.0Obtaining 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.7100.0Published Name : oem1.inf
Original File Name : vx6000.inf
Inbox : No
Class Name : Image
Provider Name : Microsoft
Date : 7/18/2008
Version : 5.5.3.74The operation completed successfully.
我们现在已经完成映象的维护,接下来把它卸载:
C:\Program Files\Windows AIK\Tools\PETools>dism /unmount-wim /mountdir:C:\Servicing /commit
Deployment Image Servicing and Management tool
Version: 6.1.7100.0
Image File : C:\Images\install.wim
Image Index : 4
Saving p_w_picpath
[==========================100.0%==========================]
Unmounting p_w_picpath
[==========================100.0%==========================]
The operation completed successfully.
转载于:https://blog.51cto.com/zhiwen/298395