Monday 30 May 2016

Steps to make .cab file from .dll

If you want to make a cab from your dll its pretty simple by using Makecab utility

Simple steps to make  cabinet (.cab) file from dll


  1. Create build.ddf file
  2. Create setup.inf file
  3. In cmd run Makecab.exe /f "D:\mykey\a\build.ddf"



In details,

First of all i am making a directory D:\mykey\a\
We have 3 dll files which we want to register as com using ActiveX

  • eTPKCS11DotNet.dll
  • Interop.CERTENROLLLib.dll
  • Wnisafe.dll



in the same directory i created 2 files named
setup.inf
build.ddf


Having text setup.inf

[version]
    signature="$CHICAGO$"
    AdvancedINF=2.0

 [Add.Code]
    Wnisafe.dll=Wnisafe.dll
    eTPKCS11DotNet.dll=eTPKCS11DotNet.dll
    Interop.CERTENROLLLib.dll=Interop.CERTENROLLLib.dll
    

 [Wnisafe.dll]
    file-win32-x86=thiscab
    clsid={A3AAA0DE3-E346-4EB8-BBFF-D3DD8AAAE5D4} 
    RegisterServer=yes
 [eTPKCS11DotNet.dll]
    file-win32-x86=thiscab
    FileVersion=9,0,14,0
    RegisterServer=yes 
 [Interop.CERTENROLLLib.dll]
    file-win32-x86=thiscab
    RegisterServer=yes 



Text of build.ddf

.OPTION EXPLICIT
.Set CabinetNameTemplate=WinMyCab.cab       
.set DiskDirectoryTemplate=Cab
.Set CompressionType=MSZIP
.Set UniqueFiles="OFF"
.Set Cabinet=on
D:\mykey\a\Wnisafe.dll
D:\mykey\a\eTPKCS11DotNet.dll
D:\mykey\a\Interop.CERTENROLLLib.dll
D:\mykey\a\setup.inf

Note:

  • DiskDirectoryTemplate=Cab means D:\mykey\a\Cab
  • CabinetNameTemplate=WinMyCab.cab  means D:\mykey\a\Cab\WinMyCab.cab 
  • Create Cab files of MSI file, if size in in MB
    • .Set MaxDiskSize=0
    • .Set ReservePerCabinetSize=6144
     


Now just in cmd type Makecab.exe /f "D:\mykey\a\build.ddf"

And see output like this: