Home > .Net, Miscellaneous, Office Interoperability, sharepoint > Creating CAB files using MakeCab.exe

Creating CAB files using MakeCab.exe

If you are working with Sharepoint or Infopath sometime you need to use makecab.exe, it is a command line utility to create cab files from Microsoft. You can use makecab utility from command prompt.

Command line output from MakeCab/?


MAKECAB [/V[n]] [/D var=value ...] [/L dir] source [destination]
MAKECAB [/V[n]] [/D var=value ...] /F directive_file [...]

source  - File to compress.
destination  - File name to give compressed file. If omitted, the
last character of the source file name is replaced
with an underscore (_) and used as the destination.
/F directives - A file with MakeCAB directives (may be repeated).
/D var=value - Defines variable with specified value.
/L dir - Location to place destination (default is current directory).
/V[n] - Verbosity level (1..3)

But I was unable to create the cab file with multiple files using this. After a long search I found one solution from MSDN – Using MakeCab.exe. Then I have created one .ddf file and using the command


makecab.exe /f Sample.ddf

And in the sample.ddf you can specify the file names.


;*** Sample Source Code MakeCAB Directive file example
;
.OPTION EXPLICIT ; Generate errors
.Set CabinetNameTemplate="Sample.cab"
.set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory
.Set CompressionType=MSZIP;** All files are compressed in cabinet files
.Set UniqueFiles="OFF"
.Set Cabinet=on
.Set DiskDirectory1="Cabs"
image1.gif
image2.gif
mystyle.xsl
manifest.xsf
myschema.xsd
script.vbs
template.xml
upgrade.xsl
;*** <the end>

I think the code is self explanatory.

  1. Gaurav
    September 5th, 2008 at 13:02 | #1

    Just thought i’d give you a small insight for an easier way to do this. you can download a software called “Cab Maker”. after installation (and maybe registering the comdlg32.ocx in the application folder), simply drag and drop the files for which you want the CAB to be created. press start and watch the file get prepared for you. Cab Maker also generates the DDF file in case you wish to use makecab through command prompt

  2. September 5th, 2008 at 23:46 | #2

    Thanks Gaurav for the Information. I am just providing link of SoftPedia where you can download this software

    http://www.softpedia.com/get/Compression-tools/Cab-File-Maker.shtml
    :)

  3. Jiljith C P
    April 21st, 2009 at 12:54 | #3

    Thanks a lot!
    Couldn’t find another immediate link on the web with quick steps to complete this.
    Worked fine.

    Thanks

    Jiljith.

  4. April 22nd, 2009 at 08:41 | #4

    Thanks Jiljith :)

  1. No trackbacks yet.