makecab


MakeCAB.exe is a tool included with Windows 2000 or later



$ which makecab.exe
/cygdrive/c/Windows/system32/makecab.exe

smnb@vista WSDK ~/myprog/gadget/hellos/hello2
$ makecab
Cabinet Maker - Lossless Data Compression Tool

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). Refer to
                 Microsoft Cabinet SDK for information on directive_file.
  /D var=value   Defines variable with specified value.
  /L dir         Location to place destination (default is current directory).
  /V[n]          Verbosity level (1..3).

steps

  1. Create a directive file for makecab.exe, and save the file with a .ddf extension.
    
    ;*** Sample Source Code MakeCAB Directive file example
    ;
    .OPTION EXPLICIT     ; Generate errors 
    .Set CabinetNameTemplate=SampleCab.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=SAMPLECAB.CAB
    manifest.xml
    WebPart1.dwp
    WebPartLibrary1.dll
    "space in between" 
    .Set DestinationDir=de-DE
    de-DE\WebPart1.dwp 
    de-DE\image1.gif 
    de-DE\help.htm
    ;*** <the end>
    
  2. Copy all the files that you want to include in the .cab file into the directory where you created the .ddf file.
  3. Open a command prompt, change to the directory that contains the .ddf file, and then run the following command:
    Makecab.exe /F sample.ddf

ref

 

memo

.cabをリネームしたrelease.gadget をダブルクリックすると不明な発行者になる

 

 

MAKECAB.EXE Directive File Syntax

 

some notes on the general syntax and behavior of MakeCAB Directive Files

  1. MakeCAB will place files on disks (and in cabinets) in the order they are specified in the directive file(s).
  2. a filename or directory can be either a relative  or an absolute path.
  3. MakeCAB is controlled in large part by setting variables. You can modify these variables, and you can define your own variables as well.
  4. The value of a variable is retrieved by enclosing the variable name in percent (%) signs. If the variable is not defined, an error is generated.
  5. explicit percent sign, use two adjacent percent signs (%%).
  6. Variable substitution is only done once.
  7. Variable substitution is done before any other line parsing, so variables can be used anywhere.
  8. Variables values may include blanks. Quote (“) or apostrophe(‘) marks may be used in .
  9. If you want an explicit quote(“) or apostrophe(‘), you can intermix these two marks  ex. '+"+'  or "+'+"
  10. All sizes are specified in bytes.

Directive File - Command Summary

Syntax Description
; Comment (anywhere on a DDF line)
src [dest] [/inf=yes|no] [/unique=yes|no] [/x=y ...] File Copy command
dest [/x=y ...] File Reference command
.Define variable=[value] Define variable to be equal to value (see .Option Explicit)
.Delete variable Delete a variable definition
.Dump Display all variable definitions
.InfBegin Disk | Cabinet | Folder Copy lines to specified INF file section
.InfEnd Endian .InfBegin section
.InfWrite string Write “string” to file section of INF file
.InfWriteCabinet string Write “string” to cabinet section of INF file
.InfWriteDisk string Write “string” to disk section of INF file
.New Disk | Cabinet | Folder Start a new Disk, Cabinet, or Folder
.Option Explicit Require .Define first time for user-defined variables
.Set variable=[value] Set variable to be equal to value
%variable% Substitute value of variable
<blank line> Blank lines are ignored

Variable Summary

Standard Variables Description
Cabinet=ON | OFF Turns Cabinet Mode on or off
CabinetFileCountThreshold=count Threshold count of files per Cabinet
CabinetNamen=filename Cabinet file name for cabinet number n
CabinetNameTemplate=template Cabinet file name template; * is replaced by Cabinet number
ChecksumWidth=1 | 2 | ... | 8 Max low-order hex digits displayed by INF csum parameter
ClusterSize=bytesPerCluster Cluster size on diskette (default is 512 bytes)
Compress=ON | OFF Turns compression on or off
CompressedFileExtensionChar=char Last character of the file extension for compressed files
CompressionType=MSZIP Compression engine
DestinationDir=path Default path for destination files (stored in cabinet file)
DiskDirectoryn=directory Output directory name for disk n
DiskDirectoryTemplate=template Output directory name template; * is replaced by disk number
DiskLabeln=label Printed disk label name for disk n
DiskLabelTemplate=template Printed disk label name template; * is replaced by disk number
DoNotCopyFiles= ON | OFF Controls whether files are actually copied (ACME ADMIN.INF)
FolderFileCountThreshold=count Threshold count of files per Folder
FolderSizeThreshold=size Threshold folder size for current folder
GenerateInf=ON | OFF Control Unified vs. Relation INF generation mode
InfXxx=string Set default value for INF Parameter Xxx
InfCabinetHeader[n]=string INF cabinet section header text
InfCabinetLineFormat[n]=format string INF cabinet section detail line format
InfCommentString=string INF comment string
InfDateFormat=yyyy-mm-dd | mm/dd/yy INF date format
InfDiskHeader[n]=string INF disk section header text
InfDiskLineFormat[n]=format string INF disk section detail line format
InfFileHeader[n]=string INF file section header text
InfFileLineFormat[n]=format string INF file section detail line format
InfFileName=filename Name of INF file
InfFooter[n]=string INF footer text
InfHeader[n]=string INF header text
InfSectionOrder=[D | C | F]* INF section order (disk, cabinet, file)
MaxCabinetSize=size Maximum cabinet file size for current cabinet
MaxDiskFileCount=count Maximum count of files per Disk
MaxDiskSize[n]=size Maximum disk size
MaxErrors=count Maximum errors allowed before pass 1 terminates
ReservePerCabinetSize=size Base amount of space to reserve for FCRESERVE data
ReservePerDataBlockSize=size Amount of space to reserve in each data block
ReservePerFolderSize=size Amount of additional space in FCRESERVE for each folder
RptFileName=filename Name of RPT file
SourceDir=path Default path for source files
UniqueFiles=ON | OFF Control whether duplicate desintation file names are allowed