You are not logged in.

#1 07 Nov 2013 11:43

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 446

creating self-extracting executables with makecab

I'm continuing my childish games with makecab 

In the documentation is mentioned the possibility to create a self-extracting archive:

copy /b extract.exe+self1.cab self.exe  ; self.exe is self-extracting

But extract is no more available nor in Vista neither in Win7.But after few tests I succeeded to create a self-extracting exe with  extrac32.exe .extrac32.exe is an UI application and does not print any help but when executed with an .CAB file as a parameter it will extract it (may be with makecab generated inf file it will be possible to do more things?).

and here's a pretty pretty simple script that creates an self-extracting file:

@echo off

if "%~2" equ "" (
	echo creates self-extracting exe
	echo USAGE: %~n0 target destination	
)

makecab "%~f1" "%temp%\%~n1.cab"
copy  /b  "%windir%\system32\extrac32.exe"+"%temp%\%~n1.cab" "%~dpn2.exe"
del /q /f "%temp%\%~n1.cab"

EDIT: to get extrac32 help use more --> http://researchbin.blogspot.com/2012/05 … es-in.html

Last edited by npocmaka (07 Nov 2013 17:37)

Offline

#2 01 Dec 2013 19:14

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: creating self-extracting executables with makecab

I have now added a page for MAKECAB
https://ss64.com/nt/makecab.html

Offline

#3 03 Dec 2013 16:11

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 446

Re: creating self-extracting executables with makecab

Great :-) .
Still don't see it in the list page ... (but I've saw that now EXTRACT and EXPAND are separated )
May be few more things worth to be mentioned   ~ t var=value pairs are in fact directives  ; the possibility to create hybrid bat/directive file as ";" is delimiter for the bat and comment for the makecab; accessible file properties (some of them are accessible only by makecab from the default windows commands - like the version for the binaries. ) ; may be the get time function that relies on makecab  as it is localization independent and available for all windows machines....
later will try to create example text pages for COMPRESS and COMPACT ..

Offline

#4 13 Jan 2014 21:04

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 446

Re: creating self-extracting executables with makecab

Just a reminder to add the makecab to the ss64/nt list smile .And a few suggestions for improvements (the links direct to google documents):

Makecab  more descriptive ..ahmm descriptions for the command switches , example with extraction of sliced files , example with a self-containing directives script and related pages.

MakeCab directives -added undocumented types of compression found by carlos  (http://ss64.org/viewtopic.php?id=1597) , escape fir % in variables definition and a table with the inf parametes.

Expand - added a quote as the ss64/nt page does not have one , mentioned the bug when you try to retrieve the help of the command , additional switches from vista and above.

compress - I was surprised to find out that this is an Win 2003 resource tool kit utility.



.
.
.
.
.
.
.




I've done also some test with file splitting :

;@echo off

;;;;; rem start of the batch part  ;;;;;
;;
;; rem too lazy to add print help function
;; rem the first parameter is the file you want to split  the second is the size in bytes
;makecab /d the_file="%~1"  /d the_size="%~2" /F "%~dpfnxs0"
;exit /b 0

;;
;;;; rem end of the batch part ;;;;;

;;;; directives part ;;;;;
;;
.New Cabinet
.set GenerateInf=OFF
.Set Cabinet=on
.Set Compress=on
.Set MaxCabinetSize=%the_size%
;.set CabinetFileCountThreshold=1
.set CompressedFileExtensionChar=_
.Set CabinetNameTemplate=%the_file%_part*.cab
.set DestinationDir=;
.set DestinationDir=.
.Set DiskDirectoryTemplate=; 

.set RptFileName=nul
.set UniqueFiles=ON
;.set DoNotCopyFiles=ON
;.set MaxDiskFileCount=1
.set MaxErrors=1
.set GenerateInf=OFF
%the_file% /inf=no
;;
;;;; end of directives part ;;;;;

and according to my test MaxCabinetSize does not guarantee the exact size of each part , only that they will not overflow the given size. The only way that I 've found to expand the produced .cab parts is to put them all in one directory and prepend the extrac32 to the first one with copy /b   and to create an exe.Then the executable will extract all parts in one file.

Last edited by npocmaka (29 Jan 2015 07:17)

Offline

#5 12 Feb 2014 00:40

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: creating self-extracting executables with makecab

Offline

#6 13 Feb 2014 21:44

npocmaka
Member
From: Bulgaria
Registered: 03 Dec 2009
Posts: 446

Re: creating self-extracting executables with makecab

Thanks . I appreciate this (and hope not overloading you with work) .

Offline

#7 15 Feb 2014 11:43

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: creating self-extracting executables with makecab

npocmaka wrote:

Thanks . I appreciate this (and hope not overloading you with work) .

Feedback is always good even if it does take me a while to catch up sometimes smile

Offline

#8 13 Apr 2015 20:30

carlos
Member
From: Chile
Registered: 04 Nov 2008
Posts: 251
Website

Re: creating self-extracting executables with makecab

Hello. I found all the makecab directives with the default values with this:

echo .Dump>foo.inf
makecab /F foo.inf

it prints:

MakeCAB Variables (in order of their definition)
------------------------------------------------
    Cabinet(Standard)=<1>
    CabinetFileCountThreshold(Standard)=<0>
    CabinetNameTemplate(Standard)=<*.cab>
    ChecksumWidth(Standard)=<8>
    ClusterSize(Standard)=<512>
    Compress(Standard)=<1>
    CompressedFileExtensionChar(Standard)=<_>
    CompressionType(Standard)=<MSZIP>
    CompressionLevel(Standard)=<2>
    CompressionMemory(Standard)=<18>
    DestinationDir(Standard)=<>
    DiskDirectoryTemplate(Standard)=<disk*>
    DiskLabelTemplate(Standard)=<Disk *>
    DoNotCopyFiles(Standard)=<0>
    FolderFileCountThreshold(Standard)=<0>
    FolderSizeThreshold(Standard)=<0>
    GenerateInf(Standard)=<1>
    InfCabinetHeader(Standard)=<[cabinet list]>
    InfCabinetLineFormat(Standard)=<*cab#*,*disk#*,*cabfile*>
    InfCommentString(Standard)=<;>
    InfDateFormat(Standard)=<mm/dd/yy>
    InfDiskHeader(Standard)=<[disk list]>
    InfDiskLineFormat(Standard)=<*disk#*,*label*>
    InfFileHeader(Standard)=<[file list]>
    InfFileLineFormat(Standard)=<*disk#*,*cab#*,*file*,*size*>
    InfFileName(Standard)=<setup.inf>
    InfFooter(Standard)=<%1*** END ************************************************************>
    InfFooter1(Standard)=<%1**                                                                **>
    InfFooter2(Standard)=<%1** Automatically generated on: %2           **>
    InfFooter3(Standard)=<%1**                                                                **>
    InfFooter4(Standard)=<%1*** END ************************************************************>
    InfHeader(Standard)=<%1*** BEGIN **********************************************************>
    InfHeader1(Standard)=<%1**                                                                **>
    InfHeader2(Standard)=<%1** Automatically generated on: %2           **>
    InfHeader3(Standard)=<%1**                                                                **>
    InfHeader4(Standard)=<%1** MakeCAB Version: %3                                 **>
    InfHeader5(Standard)=<%1**                                                                **>
    InfHeader6(Standard)=<%1*** BEGIN **********************************************************>
    InfSectionOrder(Standard)=<DCF>
    MaxCabinetSize(Standard)=<0>
    MaxDiskFileCount(Standard)=<224>
    MaxDiskSize(Standard)=<1457664>
    MaxErrors(Standard)=<20>
    ReservePerCabinetSize(Standard)=<0>
    ReservePerDataBlockSize(Standard)=<0>
    ReservePerFolderSize(Standard)=<0>
    RptFileName(Standard)=<setup.rpt>
    SourceDir(Standard)=<>
    UniqueFiles(Standard)=<1>
0 bytes in 0 files
Executing directives

I found that exists a undocumented but unused directive: CompressionLevel
It was used in a old makecab.exe called diamond.exe in a old version, when it uses the compression QUANTUM instead of LZX.
I verified the usage and added to http://ss64.org/viewtopic.php?id=1597
see the info about creating QUANTUM files.
Today, makecab cannot compress with QUANTUM, because it that directive is not useful.

Last edited by carlos (13 Apr 2015 20:36)

Offline

Board footer

Powered by