Latest posts by Michael Pietroforte (see all)
- Result of the 4sysops 2016 topic poll - Tue, Apr 5 2016
- New free eBooks for SysAdmins and DevOps – VMware NSX, Windows 10, SQL Server 2016 - Mon, Mar 14 2016
- Introducing the 4sysops IT pro network - Tue, Mar 1 2016
Before you start working with an image, you might want to have some information about the image. The following command retrieves information about the OS images that are contained within a WIM file. As you probably know, a WIM image can contain multiple OS images.
I used Windows 7 Beta’s WIM file, which you can find in the “sources” folders on the DVD. If you add the command line option /index plus the image’s index number, you will get information about a specific image such as the OS version, size, installed service pack, etc. (see screenshot).
Before you can work with a WIM image, you have to mount it to a folder. DSM’s syntax differs from that of imageX. Perhaps DSM’s is easier to read in scripts, but it also requires more typing work, than imageX’s:
dism /Mount-Wim /wimfile:c:\wim\install.wim /index:4 /MountDir:c:\img
Note that if you mount an image onto a DVD, you have to add “/ReadOnly” to the command. DISM parameters are not case sensitive, so you can spare a few keystrokes if you want. You have to replace “c:\wim\install.wim” with the location where you copied the WIM file, and “c:\img” with the folder in which you want to mount the WIM image. “/index:4” specifies the fourth OS image within the WIM image, which is Windows 7 Ultimate in install.wim.
Once you have mounted an image, you can navigate through its folder structure using Windows Explorer, and make changes to all files and folders. In most cases, however, you will be using DISM to gather specific information about an image and also to add features, drivers, and packages.
dism /image:c:\img /Get-Drivers
The DISM documentation describes commands that are used to retrieve information as “management tasks.” This is a bit odd because usually “management” also implies making changes to the managed object. Other examples of such management operations include Get-Features (Windows features), Get-Packages (feature packs, language packs, updates, etc.), and /Get-Intl (international settings and languages).
All commands that are related to changing an image are called “servicing tasks.” The next command is such a servicing task, which disables the Solitaire game in Windows 7.
dism /image:c:\img /Disable-Feature:Solitaire
Note that you have to know the exact name if you want to enable or disable Windows features. You can enumerate all Windows features with this command:
dism /image:c:\img /Get-Features | more
Because there are more features than would fit on the screen, you have to use the pipe plus “more”; this will display the features a page at a time.
Whenever you make several changes, you should save the image’s current state. This command will apply to all changes you make.
dism /Commit-Wim /MountDir:c:\img
You also can apply changes once you are finished and want to unmount the image.
dism /Unmount-Wim /MountDir:c:\img /commit
If you don’t want to apply the changes, you can use the /discard parameter instead of /commit.
dism /online /Get-Packages
This command lists all packages installed on your Windows computer. Essentially, the /online option works like the /image parameter, but manages or services an “online image,” and not an offline image.
DISM certainly is a powerful tool. In this article, I have only scratched the surface. You can find all of DISM’s command line options in the WAIK (Windows Automated Installation Kit) documentation.
I have only one complaint about DISM. Some days ago, I attended a Microsoft online meeting that introduced DISM. One of the participants asked why there is no GUI version of DISM. A Microsoft developer answered that a command line tool can be used in scripts to automate tasks on multiple images. Well, this is the standard excuse for delivering command line tools. Of course, it is also possible to automate all kinds of tasks with a well-programmed GUI tool. The point is that the development of a GUI tool is more costly than a command line utility. The good news is that the developer also said that Microsoft is planning to release a GUI version of DISM in the future.