Make Your Own CAB Files with MakeCab.EXE

By | 2024-06-27

Ever need to compress a bunch of files for distribution or storage? While ZIP is a familiar format, Windows offers a lesser-known option: Cabinet files, identified by the CAB extension. Makecab.exe, a command-line tool, lets you create and manage these efficient archives.

What is a CAB file?

A CAB file, which stands for Cabinet file, is a type of archive format used on Windows systems. It essentially acts like a digital container that holds multiple compressed files and folders within it.  These files are typically used by Microsoft and its installers to group program files together  in a single, smaller file for easier distribution and storage.

Here’s a breakdown of some key points about CAB files:

  • Function: Stores compressed files and folders related to software installations, updates, or system files.
  • Benefits: Reduced file size for easier storage and transfer.
  • Identification: CAB files have the extension “.cab” at the end of the filename.
  • Opening: Windows can usually recognize and open CAB files by default. However, you can also use file extraction tools like 7-Zip to open and extract the contents of the CAB file.

Why Use CAB Files?

While ZIP is widely recognized, CAB files offer some advantages:

  • Integration with Windows Installer: If you’re deploying software or updates, CAB files work seamlessly with the built-in Windows Installer (MSI).
  • Smaller Size: In some cases, CAB files can achieve a slightly higher compression ratio than ZIP, especially for specific file types.

Getting Started with Makecab

Makecab comes pre-installed with Windows. To use it, open the Command Prompt and navigate to the directory containing the files you want to compress. Here’s the basic syntax:

makecab source [destination]

source: Replace this with the path to a single file or a folder containing your files.

destination (optional): This specifies the name of the output CAB file. If omitted, Makecab creates a filename based on the source.

For example, to create a CAB file named “myfiles.cab” from the contents of the “documents” folder, you’d use:

makecab "C:\Users\YourUsername\Documents" myfiles.cab

Specifying Files with a Directive File

Compressing an entire folder is convenient, but what if you only want specific files? Here’s where makecab’s directive files come in. These text files list the files and folders you want to include.

Create a file (e.g., files.txt) with the file paths you want to compress, one per line.  Here’s an example of the file contents for a directive file:

.OPTION EXPLICIT
;CabinetNameTemplate is the name of the output CAB file:
.Set CabinetNameTemplate=TargetFileName.CAB
.Set Cabinet=on
.Set Compress=on
"MyFile001.txt"
"AnotherFileHere.doc"
"ThirdFileHere.cfg"
"TheLastFile.xml"

Then, use the /f option with Makecab to reference the directive file:

makecab /f files.txt

This will make a cab file with the filename TargetFileName.CAB, containing the four file specified in the directive file.

Advanced Options: Specifying Compression and More

Makecab offers various options for customizing your CAB files. Here are a few:

  • Compression Level: Use the /mx option (where x is a number from 1 to 9) to control compression strength. Higher numbers result in smaller files but take longer to create.
  • Cabinet Splitting: If your archive exceeds a certain size, you can split it into multiple CAB files using the /m option followed by the desired maximum size in kilobytes.

For a full list of options and detailed explanations, refer to the official Microsoft documentation.

CAB Files: A Handy Tool in Your Windows Arsenal

While ZIP remains a popular choice, Makecab offers a powerful alternative for creating Windows-specific archives, particularly for software deployments. With its command-line interface, Makecab might seem intimidating at first, but the basic functionalities are straightforward. So, next time you need to compress files and want to explore options beyond ZIP, give Makecab a try!

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.