This post describes the process of compressing files into an external .CAB using WiMakCab.vbs.  WiMakCab.vbs is part of the Windows SDK, and can be used to compress external files into a .CAB file.  We recently used this approach to compress external files for Silverlight as follows:

Step 1 – Download and extract Silverlight

The Silverlight download comes in the form of a self extracting executable.  We used 7Zip to extract the contents of the executable to a location called C:\SilverlightDownload, which gave us silverlight.msi and silverlight.7z.  We then extracted silverlight.7z to the same folder, which gave us a patch (.MSP) called Silverlight.msp.

Step 2 – Perform an administrative installation

We used the MSI to perform an administrative installation as follows:

msiexec /a "C:\SilverlightDownload\silverlight.msi" TARGETDIR="C:\SilverlightAdmin"

 

Step 3 – Patch the administrative installation

We then patched the administrative install with silverlight.msp:

msiexec /a C:\SilverlightAdmin\silverlight.msi /p "C:\SilverlightDownload\Silverlight.msp"

 

Step 4 – Compress files into an external .CAB

Copy WiMakCab.vbs and makecab.exe into the administrative installation folder (C:\SilverlightAdmin in our case).  We found that if we didn’t run it from the same location that the .CAB file was not created.  Run the following command (where Data1 is the name of your required.CAB file):

cd c:\SilverlightAdmin
cscript WiMakCab.vbs /C /U silverlight.msi Data1

You should now see a file created called Data1.cab.  Delete everything except for Silverlight.MSI and Data1.CAB.  Done.

For more information on parameters (changing compression type, streaming the .CAB internally), please see here: http://msdn.microsoft.com/en-us/library/aa368616(v=vs.85).aspx

Note: On occasions I’ve had to remove the compressed bit from the file attributes to ensure the source files can be located.  This involves subtracting 8192 from the file attribute for each file that has it set.

Compressing Files into an External .CAB using WiMakCab.vbs
Comments have now been disabled. If you have a question to ask about this post please ask the community!