Tuesday, September 29, 2009

Squeezing a Cabinet file.

As part of our applications automatic update process we transfer a CAB file to the client side that contains the required updates.

Lately we've being using certain components that are increasing the "weight" of our applications to the point that it is becoming a bit slow to transfer these cab files. The immediate solution to this situation was to review the compression rate of the CAB files to compensate for the additional weight of the applications.

The interesting part of this "simple" procedure was to look at the command line help of the makecab.exe, around four lines and none of them telling us what we could do to help us on this topic. Nothing that some searching and reading can not fix, so if anyone ever has the need of adjusting its CAB compression ratio here it is the solution:

The CAB format allows you to use three compression methods: Deflate, Quantum and LZX. Obviously we pick the always effective LZX algorithm, which you can enable by using this command:

MAKECAB.exe /D CompressionType=LZX /D CompressionMemory=21 /L ..\Output File1 File2.CAB

Where File1 is the file you want to compress and File2.cab is the resulting file. "/L" indicates an output directory. CompressionMemory is the level of compression under the algorithm in question, 21 seems to be the highest.