论坛风格切换
正版合作和侵权请联系 sd173@foxmail.com
 
  • 帖子
  • 日志
  • 用户
  • 版块
  • 群组
帖子
购买邀请后未收到邀请联系sdbeta@qq.com
  • 2163阅读
  • 1回复

[win7相关]企业 Windows 7 部署指南之二——使用DISM [复制链接]

上一主题 下一主题
离线zhb_3448
 

发帖
59686
今日发帖
最后登录
2016-12-13
只看楼主 倒序阅读 使用道具 楼主  发表于: 2009-10-20 20:17:49
 了解DISM  DISM.exe是新的命令行工具,在操作系统Windows 7的默认安装中和自动安装工具Windows AIK 2.0中都可以看到该工具的身影。
  注意:以可启动的Windows镜像方式对VHD文件提供支持是Windows 7中出现的一个新功能,我们会在本系列其他文章中对该功能进行介绍。
  我们可以使用DISM.exe操作Windows镜像,这其中包括Windows 镜像文件(WIM)和虚拟硬盘文件(VHD)。虽然DISM.exe主要用于操作离线的Windows 镜像,但是它的一些功能也可以用来为在线的Windows操作系统提供管理。我们所说的操作镜像意指添加或删除设备驱动,添加或删除操作系统补丁,添加hotfixes,配置镜像的区域设定以及其他相应操作。DISM还可以用来将Windows镜像更新至不同版本(如从商业版更新至旗舰版),并准备一个Windows PE镜像以供使用。
  我们可以用DISM对以下版本的镜像进行修复:
   ·Windows Vista SP1 及之后版本
   ·Windows Server 2008
   ·Windows 7
   ·Windows Server 2008 R2
  使用DISM
  在Windows Vista(或Windows AIK 1.1)中编辑一个镜像需要使用若干不同的工具。例如我们要在主安装的镜像上安装一个不合常规的设备驱动,如果想在Vista中实现这一操作,要按照以下步骤:
   1.用ImageX装载镜像
   2.用数据包管理器(Pkgmgr.exe)添加设备驱动器
   3.用ImageX卸载镜像
  此外,如果我们的镜像是一个Windows PE镜像,那么还需要使用Windows Preinstallation Environment(PEimg.exe)工具来配置该镜像。最后,如果需要修改镜像的语言和本地设置,我们还要使用International Settings Configuration Tool(Intlcfg.exe)。
  但是,如果要在Windows 7中完成这一操作,要怎么办呢?DISM.exe现在已经取代了早前Windows AIK 1.1版本中的Pkgmgr.exe,Intlcfg.exe和PEimg.exe工具。另外,DISM还包括装载和卸载镜像的功能,因此我们可以对镜像进行编辑。
  通常,我们利用DISM把某个设备驱动添加到离线的Windows 镜像中,然后再将该镜像部署到需要这一驱动的硬件上。让我们浏览一遍完成该操作的命令行以便学习如何使用DISM。
  首先,在我们的Windows AIK 2.0电脑上的C:\Images 文件夹中可以找到一个用于Windows 7的Windows安装镜像(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


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的空文件夹中。先让我们使用带有 /get-wiminfo 参数的DISM.exe命令行来显示包含在install.wim文件中的所有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 image : 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 专业版,在此案例中,从上面的命令行中可以看出,在这一特定镜像中,Index数为4。因此,让我们利用DISM.exe命令中的 /mount-wim 参数把这一特定Windows镜像加载到空的C:\Servicing 文件夹中。
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 image
[==========================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 images:

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 /image: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 image:

WINDOWS EDITION SERVICING COMMANDS:

  /Set-ProductKey         - Populates the product key into the offline image.
  /Get-TargetEditions     - Displays a list of Windows editions that an image can be upgraded to.
  /Get-CurrentEdition     - Displays the editions of the specified image.
  /Set-Edition            - Upgrades the Windows image to a higher edition.

UNATTEND SERVICING COMMANDS:

  /Apply-Unattend         - Applies an unattend file to an image.

DRIVER SERVICING COMMANDS:

  /Remove-Driver          - Removes driver packages from an offline image.
  /Add-Driver             - Adds driver packages to an offline image.
  /Get-DriverInfo         - Displays information about a specific driver in an offline image or a running operating system.
  /Get-Drivers            - Displays information about all drivers in an offline image 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 image.
  /Set-UILangFallback     - Sets the fallback default language for the system UI in the mounted offline image.
  /Set-UserLocale         - Sets the user locale in the mounted offline image.
  /Set-SysLocale          - Sets the language for non-Unicode programs (also called system locale) and font settings in the mounted offline image.
  /Set-InputLocale        - Sets the input locales and keyboard layouts to use in the mounted offline image.
  /Set-TimeZone           - Sets the default time zone in the mounted offline image.
  /Set-AllIntl            - Sets all international settings in the mounted offline image.
  /Set-SKUIntlDefaults    - Sets all international settings to the default values for the specified SKU language in the mounted offline image.
  /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 image.
  /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 image.
  /Remove-Package         - Removes packages from the image.
  /Enable-Feature         - Enables a specific feature in the image.
  /Disable-Feature        - Disables a specific feature in the image.
  /Get-Packages           - Displays information about all packages in the image.
  /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 image.

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 /image: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 /image: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.
Let's use /get-drivers again to verify that the LifeCam driver has been successfully added to the mounted image:
C:\Program Files\Windows AIK\Tools\PETools>dism /image: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

Published Name : oem1.inf
Original File Name : vx6000.inf
Inbox : No
Class Name : Image
Provider Name : Microsoft
Date : 7/18/2008
Version : 5.5.3.74

The 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 image
[==========================100.0%==========================]
Unmounting image
[==========================100.0%==========================]
The operation completed successfully.


  其他资源
  要获取更多有关DISM.exe的使用信息,在Deployment Tools Command Prompt中输入dism/?。另外,还可以点击“开始”菜单,从程序中找到Windows AIK用户指导(WAIK.chm),在其中的Deployment Tools Technical Reference部分也可以找到有关DISM.exe的详细信息。

主队让半球高水,一般不能要主队!
凡是开半一的盘,一般不能要下盘!
凡是开一球或一球球半的盘,一般不能要上盘!
凡是开一球半以上的盘,一般不能要下盘!
离线quen2008
发帖
*
今日发帖
最后登录
1970-01-01
只看该作者 沙发  发表于: 2009-10-21 08:42:51
没用过这个软件,感觉功能很强啊