How to get file's compressed size inside an msi?

Question

How to get file's compressed size inside an msi?

Answer

Windows Installer SDK tools like PatchWiz.dll and WiMakCab.vbs with msifiler.exe will compress files into a cabinet (.cab) file either separate or added as a sub-storage of the MSI, MSP, or MSM itself.

To get the compressed size, you can

  1. figure out which CAB a file is by examining the File table sequence column and Media table. More context is available from the MSDN article Ordering File Sequence Numbers in a Cabinet, File Table and Media Table
  2. depending on your implementation, you may have to extract the CAB if it’s in a sub-storage. Windows Installer SDK tools msidb.exe and orca.exe can help extract the cab from the MSI.
  3. use the Cabinet APIs to get the compressed size of the file

If reducing patch size is your goal, check out MSDN topic: Reducing Patch Size

Content credit also belongs to

  • Heath, Microsoft Dev. You can get other Heath insights about developing for Windows Installer from his blog Heath Stewart's Blog

[Author: Robert Flaming]

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at https://www.microsoft.com/info/cpyright.htm.