MSI One-Click Unpacker
Last update 1/4/2011
___________________________

JSWare
www.jsware.net

 This utility is a basic MSI/MSM unpacker written in VBScript. 
It requires nothing that is not already installed on virtually all
Windows PCs. The script can be used with drag/drop or by
command line.

______________________________
Usage:
______________________________

Drag-drop: 

  This is the easiest way to use the unpacker. Just put
the MSI file into a folder where you want the extracted files, and
then drop the MSI file onto the script.

Problems with drag-drop on Vista/7:

  HOWEVER, on Windows Vista/7 this method may not be so easy.
Under default settings there are numerous problems with Vista/7
due to permission restrictions. Windows Vista/7 is designed for
corporate workstation computers. (That's true even with the "Home" 
version.) What that means is that numerous unsafe networking functions
are enabled by default (because the network is assumed to be
trustworthy!) while people using the PC are treated as corporate 
employees with limited rights.

  If you do not fix the security restrictions on Vista/7 then you
will need to right-click and select "Run as Administrator" for most
executables to work properly. But you cannot do that in a drag-drop 
operation......

Command line:
 
 To use the command line option you need to run the script with
WScript, like so:

[path to Wscript] [Path to script] [path to MSI file]

Example:
C:\Windows\System32\wscript.exe C:\MsiUnpack.vbs C:\somefolder\file.msi

You may need quotes around all or part of that if there are spaces
in one or more of the paths.

______________________________________
Requirements
______________________________________

Windows 95 - Windows 7:

  There should be nothing extra needed on any Windows PC.
The files necessary have all been pre-installed system files
for a long time.

Linux:

  This script may be usable on Linux through WINE. For that
you will need a few things:

*CABINET.DLL

*MSVBVM60.DLL 

*Windows Script Host (includes wscript.exe, wshom.ocx, etc.)

*Windows Installer - Windows Installer is available as an update
for older Windows PCs. The update is typically named instMsi.exe.
That update installs msi.dll, msiexec.exe, etc.

  Both Windows Script host and Windows Installer involve COM
libraries that must be registered. That may not work automatically
through WINE.

___________________
Note about CAB files:
___________________

  MSI files generally store the program in a CAB file. In most
cases the CAB is embedded in the MSI database file. (An MSI
is a simple SQL database.) Larger CABs are sometimes separate
from the MSI file. In that case, the CAB file must be in the same
folder as the MSI file for unpacking.

  The file jcabxmsi.exe is a command line program written especially
for the JSWare MSI unpackers. It allows the utilities to work
without needing an external ZIP program.


___________________________________________
Minor update 1-4-11:
___________________________________________

  This is an update that will affect very few cases, but provides a
fix for some corrupted MSI files. The short story is that an occasional
MSI file has a faulty Directory table that would cause unpacking to be
partial or to fail. That is fixed. 

The full, technical story:

The MSI documentation states that the MSI Directory table, listing folders in the 
install, has 3 columns:

Directory  - unique ID of folder
Directory_Parent  - unique ID of parent folder.
DefaultDir - name of folder when installed.

  The docs further state that there can be only 1 root folder. That folder
has Directory property set to "TARGETDIR" and DefaultDir set to "SourceDir".
If there is no TARGETDIR then the ROOTDRIVE property is used. The docs also state 
that if the Directory_Parent property is the same as Directory, or if it is blank, then 
that entry represents the root folder. In the past I have only come across 1 faulty
MSI in this regard. It has two TARGETDIR entries and, oddly enough, was authored
by a very well-known Microsoft MVP. More recently I came across a second faulty
Directory table. This time it was in an installer from Microsoft themselves!
  The file name is NetworkMonitor_Parsers.msi. It comes packed inside the Network 
MS Monitor software download. In NetworkMonitor_Parsers.msi Directory table there is 
the following:

TARGETDIR	NPLROOT		PackDir|NetworkMonitor Parsers

Base				SourceDir

TARGETDIR is a keyword that should denote the root folder but it is not the root folder. 
"TARGETDIR" was just used as the alphanumeric ID of one of the folders! The root 
folder is Base. Without figuring out the root folder name, unpacking ends up being
partial at best, so this problem needed to be dealt with.
  
  The update involves a rewrite of the SortFolders sub. The new version
will look for a valid  entry that has "SourceDir" in the 3rd column, with
a 2nd column that is either blank or matches the first column. Only if no
such match is found will it then check for entries with TARGETDIR or 
ROOTDRIVE in the first column.

___________________________________________
Update Nov. 2010:
___________________________________________

 CAB extractor updated to handle multiple CABS where files span across CABs.

___________________________________________
Update Oct. 2010:
___________________________________________

 Replaced the CAB extractor with a new, smaller version that works with all Windows versions.

___________________________________________
Changes to be aware of - the 12/2009 update:
___________________________________________

  With some newer MSI installation files there is a new wrinkle. A good example is SQL Server 2008 Express from Microsoft. The download is an EXE file. (Microsoft have never recommended EXE "wrappers" around MSIs, but Microsoft have never been in the habit of following their own instructions, either.) The EXE in this case is not just an MSI wrapper. It is actually a self-executing CAB file. If the download is converted to a CAB it can be seen to contain all of the install files, named with pre-installation code names that get changed on install, plus a handful of installation files, including an MSI file. The SQL Server install requires Windows Installer v. 4.5, yet Windows Installer is largely superfluous in the installation. When the EXE is run it dumps it's contents into the TEMP folder, but in the process it also unpacks the install files, copies them to a program folder tree created in the TEMP folder, and renames them all to their correct post-install names! Since there is no embedded CAB in the MSI to unpack, the MSI Unpackers do not find any files and the Program Description log file written by the unpackers therefore does not list any files. 

 In other words, this is an inside-out MSI. Instead of being an MSI with an embedded CAB inside, the MSI is actually inside the CAB.

   Microsoft's SQL Server install is not alone in using this odd method, so you need to be aware of it for successful unpacking. You can recognize the new "wacky mode" installers because when you open the TEMP folder you'll find not only an MSI but also a full program installation, ready to be copied to the appropriate folders. The program folder is there just as it would end up being in Program Files if you completed the install!
   So the file unpacking is already done for you. You can copy those folders/files out of TEMP if you want to inspect them. But there is still an MSI file as well. The MSI still contains documentation of folders, files, Registry settings, Features, Components, etc. You can run the MSI Unpacker with that MSI file to get a log file that documents all of those things. The difference from a normal MSI is that the unpacker will not actually unpack anything, because there's nothing there to unpack. It has already been done by the installer EXE.

   The 12-09 update to the unpackers includes a change to make sure that the program files and their paths are listed in the final "Program Description.txt" log, regardless of whether those files were unpacked and renamed by the unpacker, or whether they were unpacked and renamed by the installer EXE. 

______________________________________________
License:
______________________________________________

You use all script code and components from JSWare at your own risk.

  The components (compiled DLL and EXE files) may be used for personal or
commercial purposes. No payment or attribution is required for either use.
The components may be redistributed if they are required as support files 
for scripts or software that you have written.
   Also, the script code may be used freely, in part or as whole scripts,
for any purpose, personal or commercial, without payment or attribution.

  I ask only that you not redistribute these scripts and components, except
as required for your direct use. Instead, please direct others to obtain copies
of JSWare scripts and components directly from www.jsware.net.

  Also, none of the code here may be redistributed under another license. If a 
work using code from JSWare is distributed with restrictions of any kind 
the code from JSWare must be kept exempt from those restrictions. 
This includes, but is not limited to, code sold for profit, code with usage restrictions
and code distributed as so-called "Open Source" with redistribution restrictions. 

                                         Joe Priestley

________________________________________________________________

JSWare
www.jsware.net
jsware@jsware.net

Please note: JSWare does not accept 
"webmail" from hotmail, yahoo, facebook or gmail. 
For further explanation see:
www.jsware.net/jsware/contact.php5
