How To Extract a Single File From a Large MSI (4 Ways) Print E-mail
General
Written by Darwin Sanoy   
Thursday, March 18, 2010 7:25pm

There may be times when you need a file or two out of a Microsoft SDK or other large distribution. It can be a painful process to install an entire SDK or toolkit to obtain a single file, so we’ve documented some better ways.

We use these methods in the lab exercises of our training courses when a few files are needed from large SDKs or toolkits provided by Microsoft.

The Challenge

Getting your hands on a single file from a Microsoft SDK can be a big pain. Microsoft does not provide the files individually for good reason – developer machines could end up with a very odd mix of file versions from different SDK releases – which would lead to a lot of strange problems for all of us who use software (anyone reading this not use software?)

Enjoying your read? Subscribe to our newsletter (without loosing your place in this article).
captcha
(Please ensure that the confirmation email clears your spam filter so that you will see future mailings.)

However, when you truly do need a single file, the time consuming, painful process goes something like this:

  1. Find out what massive SDK or distribution the target file is a part of.
  2. Download the SDK or distribution (go have a coffee while this step completes).
  3. Worse yet, use the web based installer which installs over the web.
  4. Install the ENTIRE SDK because there is no way to definitively know which features will include the files you are after.
  5. If you don’t want to dirty your machine – do the previous step on a Virtual Machine or a reloadable machine.
  6. Find and copy the files.
  7. Uninstall the SDK.

In the past I have used the approach of installing the SDK, copying the files to an archive location, and uninstalling the SDK so that I will have access to any other loose files I need at a later date. There are several problems with this: a) I forget where I put them!, b) I end up deleting them because it does not seem to make sense to retain 1 GB of disk space in case I might need a 10 KB file sometime in the next 18 months, c) I rebuild my machine before needing the files again, d) By the time I need them again, I need the latest files from the latest SDK.

Here are some examples of the types of files I have had to deep dive for (If you have other examples, I’d love to hear about them via our Contact Us page!):

  • from the latest download of the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 (winsdk_web.exe or GRMSDK_EN_DVD.iso or winsdk_dvdx86.msi):
    • fuslogvw.exe - for viewing .NET fusion binding logs.
    • orca.msi - to view and edit MSI files.
    • mt.exe - to add and change embedded application manifests.
  • from the latest download of the Debugging Tools for Windows (dbg_x86_6...msi) dbghelp.dll and symsrv.dll - for configuring debug symbols with Sysinternals Process Monitor (procmon.exe) or Process Explorer (procexp.exe)
  • from the latest download of the Windows Automated Installation Kit (waikx86.msi or waikx64.msi) wimgapi.dll - for use with Bartpe.

Windows Installer File Structures

Some archiving utilities do allow you to open .MSI files and attempt to extract files. However, .MSI file present at least two major challenges:

  1. The file names in the cabs do not necessarily match the final file names of files when installed. MSI allows the abstraction of file names in CABS so that you can have two completely different files that would have the same name on and installed system. For instance, if you MSI contains files for both x86 and x64 platforms, the files for each platform can be stored in the same cab under different names, but install with the same file name. Since you would never install both file types on the same exact machine, it does not matter that the names would be the same on the installed target. The file table must be consulted to resolve target file names and display them when you are using an extraction utility. Archiving programs like 7zip and izarc have little motivation to go to the extra trouble of resolving the names. In many cases, the names
  2. The files referenced in an MSI may be contained in more than one internal CAB file.

So let’s take a look at three different ways to accomplish getting a file or two out of an MSI. We will use the example of grabbing wimgapi.dll from waikx86.msi. This MSI has the following attributes: *) files name abstraction for dual x86 and x64 support (file names in cabs are not final names), *) multiple cab files, *) cab files stored internally in the MSI.

Web Installers, MSIs or ISOs

The SDK or toolkit will come as either a web installer (.EXE which downloads the individual files during the install phase), a self contained MSI file with internal cabs, or an ISO. For instance, the Windows Installer SDK is provided as a web installer and an ISO, but the Windows Debugging Tools come only as a downloadable MSI. If you decide to download the ISO file, you will need a free ISO mounting utility like Virtual Clone Drive or MagicISO Virtual CD/DVD ROM. Both of free these utilities are made by companies that also sell more capable ISO creation software – so do not let their websites confuse you into thinking you have to buy anything simply to mount an ISO.

Enjoying your read? Subscribe to our newsletter (without loosing your place in this article).
captcha
(Please ensure that the confirmation email clears your spam filter so that you will see future mailings.)

lessmsi

lessmsi is a small, standalone utility that displays the files in an MSI and allows you to extract them. It was updated to version 1.0.7 in December of 2009. It resolves our two Windows Installer file structure challenges by using the file names in the File table of the package and then finding the file in the correct cab, extracting it and naming it according to the file table name.

image

Benefits:

  • Uses final file names using MSI “File” table
  • Handles multiple-CAB MSIs.
  • GUI and command line modes are both supported.
  • Does NOT also display the CAB file names whose contents are already completely listed in the File table (true archive metaphor for a .MSI file)
  • No install is required to use the software.
  • Allows optional configuration of a shell extension.

Challenges:

  • Relatively slow on large packages.
  • Extracts all files to TARGET location (not temp) and deletes unneeded ones. Be careful if your target location is on a network - you will be pushing the entire contents of the package up there to get the one file.
  • Developer has limited time to maintain this utility – be sure you tell him how much you like it!
  • Does not work with external cabs, but does not throw an error - just does nothing.
  • Extracts file to their to full target folder structure, meaning you usually have to dig through many folder levels, copy the file out and delete the folders.
  • No search or "type to locate" filename support.

Download:

http://code.google.com/p/lessmsi/

Admin Install

Admin installs are a built-in feature of Windows Installer. Completing an admin install gives access to the software files without making any changes to the computer you use to extract the files. It simply extracts all files from the source formats and organizes them in a folder. A few changes are made to the MSI as well. No changes or installation activities happen on the machine running the admin install command line.

MSI package source files can be in one of three formats (not counting an Admin install itself):

  • Internal Cabs – software files are compressed into cabs which are stored inside the MSI.
  • External Cabs – software files are compressed into cabs which are outside the MSI.
  • Uncompressed – software files are uncompressed in folders next to the MSI. (They won’t necessarily have their final names or the folder structure of installed files.)

An admin install will take any of these formats and convert them to the admin install format – including using folders that are similar to those of the software when it is installed on a computer.

An admin install is triggered by using the “/a” switch on msiexec like this:

image

Unless the software package has been specially prepared to use admin installs to customize the package, the only prompt will be for the disk location to install the software. Despite the reference to “Network Location” on this dialog, the location can be on a local disk.

image

 

Benefits:

  • No additional software required.
  • Extracts files to their final filename – no need to guess the appropriate filename.

Challenges:

  • Does not appear to handle external CAB files.
  • No built-in shell extension (see below for registry settings to make your own)
  • Full package extraction is required to get at the files.
  • Some MSI’s block admin installs from occurring.
  • If admin install fails, all extracted files will be deleted. (e.g. The version of WAIKx86.msi I have *thinks* winpe.cab is corrupt only during an admin install and will not complete the extract.)

This registry file will add an “Extract Admin Install” context menu item to “.MSI” files:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Msi.Package\shell\Extract Admin Install\command]
@="msiexec.exe /a \"%1\""

7Zip

7zip is an archiving utility that has been given a rudimentary ability to work with MSI files. It will open them and display their file content, including cab files. Clicking a cab file will drill down into that archive similar to have archivers work with compressed archive files. However, since it does not use the files table, you are on your own to translate the filenames in the cabs into the file name you are looking for – this is usually not a difficult process. If there are multiple cab files in the MSI, you have to slog through each one. In the case of WAIK there are five internal cab files. When using lessmsi, I do not see any cab files because it uses the MSI table instead.

image

Benefits:

  • Fast (because .cabs are temporarily extracted upon viewing files in cab)
  • Does not extract entire file set to get one file.
  • Only extracts cab files opened.
  • Extracts to temp – not the target file location (important if you are targeting a network location or other slow disk)

Challenges:

  • File names in CABs may not exactly match the file name you are looking for.
  • Does not handle external CABs (because it is not looking at the file table).
  • Multiple-cab MSIs require more rooting around than lessmsi or Admin Installs because the files table is not consulted to present the list.
  • Requires an install of 7zip if you do not already have it installed.

Download:

PowerArchiver MSI Plug-in

PowerAchiver has a plug-in that extends that product to handle MSI files. Unlike 7zip and lessmsi, it DOES handle external CAB files! When using it It’s primary drawback is that it displays and extracts files according to their abstracted name (MSI File table’s “File” column rather than the “FileName” column.) This callenge is seen in the Windows SDK where many of these abstracted file names are very long. Another challenge is that it displays the .CAB files along side of the file list. The file list is of course what is in the CABs themselves. This wouldn’t be so bad if I wasn’t preprogrammed by standard compressed archive metaphors to start rummaging the sub-cabs directly. However, doing so causes the very slow extraction of that CAB and then it is displayed as a separate archive. If that CAb does not contain what you want, you must reopen the .MSI. If you decide to use this plug-in, you’ll have to teach yourself to ignore the cabs and find the file you are looking for directly in the file list – extracting it will automatically pull it out of the correct cab in the MSI. If there is only one cab, this effect is not as evident. The fact that many .MSIs only contain a single cab is probably the reason that this design issue was not picked up earlier.

image

 

Benefits:

  • Handles MSIs with external CABs.
  • Handles multiple CAB MSIs.
  • Does not extract entire file set to get one file.

Challenges:

  • Confusingly displays same CAB files that are referenced by the file list – making your cause much less productive if you start dumpster diving the cabs rather than just looking for your file on the file list
  • Uses wrong name from the MSI “File” table for the filename.
  • Not free – unless you already own PowerArchiver (plug-in is free).
  • Does not create a file association on the context menu for .MSI (so you might forget you even have this ability)
  • Requires separate plug-in install.

Downloads:

 

Add comment


Security code
Refresh