Two essential options increase your imaging capabilities
In my past few columns, I've been showing you how to use ImageX, the imaging tool that lets you reduce a prototypic PC to a single large file, which you can then easily distribute to any number of PCs. I demonstrated that the files ImageX creates—Windows image (.wim) files—can hold more than one image. Further, ImageX cleverly keeps .wim files small by never storing a file that appears in multiple images more than once, instead storing pointers to that file in images where it would otherwise be duplicated. Last month, I showed you the ImageX /append command, the key to creating multiple-image files. This month, I want to take that discussion a bit further and show you how to use ImageX to manage multiple-image .wims.
First, how do you determine whether a .wim file contains more than one image? And how do you find out what's in those images? You use the /info option, as in
imageX /info images.wim
ImageX returns a brief amount of information as text, including the number of images in the .wim file—and the rest is, unfortunately, in XML. But it's fairly simple XML, so you can easily find overall size information about each image (<DIRCOUNT>, <FILECOUNT>, and <TOTALBYTES>) and the image's descriptive name (<NAME>). The descriptive name is the one ImageX requires you to specify when you use the /capture or /append switches.
For a closer look at an image, you'd have to switch tools and use the Dism command with the /get-wiminfo option:
dism /get-wiminfo /wimfile:<filename> /index:<image-number>
For example, if you wanted to find out about the first image in images.wim, you would type
dism /get-wiminfo /wimfile:images.wim /index:1
Dism's output goes beyond byte and folder numbers and reports on the OS inside the .wim file, including SKU (e.g., Ultimate, Enterprise, Professional), service pack level, and some other useful information.
Beyond viewing image information within a .wim file, ImageX lets you remove an image from a .wim altogether with the /delete switch. To remove an image from a .wim, just type
imageX /delete <sourcewimfilename> <imagenumber|imagename> \\[/check\\]
Suppose you have a file called images.wim that contains two images, and the second image's name is EnterpriseBuild. You could remove that second image by typing either
imageX /delete images.wim 2
imageX /delete images.wim enterprisebuild
Note that image names aren't case-sensitive, wild cards don't work, and you can't use /delete to remove the only remaining image from a .wim file. Also, note that if you created the original images with the /check option (as I discussed a few columns ago), you should also use /check in your delete operation to preserve the hashes.
The .wim file's ability to hold multiple images in a single file while at the same time being stingy with your disk space is pretty nice. Sometimes, however, you'll want to pull out just a single image and put it in another .wim file. In that case, you'd use the /export switch. Its syntax looks like
imageX /export <sourcewimfilename> <imagenumber | imagename> | * <destinationwimfilename> \\["<new image name><em>"</em>\\]<em> </em>\\[/check\\]
For example, to export the third image—an image named win7kiosk—from a file named images.wim into a file named justthree.wim, you could type
imageX /export images.wim 3 justthree.wim
That command works whether justthree.wim exists or not. As with /delete, you could have replaced the 3 with win7kiosk to the same effect. The /export option is unlike /delete, however, in that it accepts the wildcard asterisk character, and in that case would export every image in images.wim into the (now sadly misnamed) justthree.wim file.
When does an asterisk make sense? Consider a case in which you have several .wim files, each of which contains a bunch of images, and you want to consolidate all your .wims into a single .wim. To accomplish that, you'd need only execute—for each of your .wim files—the command
imageX /export <filename> * masterlibrary.wim
Let's finish up with a few notes about /export, which lets you copy one or more images from one .wim file into a new .wim file. I wish Microsoft had chosen the option name /copy rather than /export because I have trouble remembering whether /export deletes an image from the source .wim file after exporting it. It doesn't. If you want the exported copy of the image to have a different name than its original one, just add one in quotes after the name of destination .wim in the /export command, as in
imageX /export images.wim 3 justthree.wim "locked-down image"
In short, if your image library is burgeoning, remember that you can save time and space by adding /delete and /export to your toolkit!