Tuesday, May 29, 2012

Making and Extracting CAB files in Windows

Cabinet files(a.k.a. Diamond files) are the Microsoft Windows Archives. These archives can store multiple files/folders into a single file with or without involving data compression. Since every Windows system is natively compatible with cab files, Windows provide enough facilities to create, extract, or rebuild cab files without requiring additional software.


By default, there are 3 utility files for dealing with cab files. They are
  • makecab.exe
  • expand.exe
  • extrac32.exe

You can find these in the system32 directory. Each of these have its own story why it's there. makecab and expand utilities are command line versions and extrac32 runs in its own Window. No matter which of them we use, we have to call from the command line(command prompt).

Creating a cab archive

makecab.exe

Open command prompt and type in
makecab
This displays the help screen with details how to call the utility and what parameters to be used
To compress a file, Simply type 
makecab [filename]
Compressed cabinet file will be saved in the same directory of the source file.

One of the big disadvantage here is that we cannot include multiple files directly. To do that, we have to create a directive file called a Diamond  Directive File(DDF) and include instructions in it. To get the whole thing automatically done,  use iexpress.exe.

Extracting a cab archive

expand.exe

For help on usage, type in
expand /?

To extract all files in an archive
expand -F:* [filename] [\destination]

Refer the documentation for more details.


extrac32.exe

Unlike expand.exe, this was intended for use with Microsoft Internet Explorer. Later, it became a part of the Windows installation. As this is not a console application, it's not very interactive with command line. Typing 'extrac32' without any parameters will simply load the utility which will terminate immediately.

To read the directives, enter
extrac32 |more

As you can see, there is a lot of facilities with this tool. Try playing around a bit and figure them out.


That's it for native Windows cab tools. Additionally, you may download the Cabinet SDK if you wish to study/utilize more of cabinet files. Most of the time we don't realize we already have the tools we are looking for. These cab tools are just another example. Knowing the tools you already have will someday save you the day.

Rate this posting:

0 comments:

Post a Comment

Toggle

About This Blog

I research on stuff; but no, not formal research. I ponder upon things I know, I dont know and I hope to know; and I might put them here, in my blog thinking my work just might help out someone hungry, hungry for knowledge.
In the end, Im just a link around here; a Hypertext.