Creating self executing .exe archieves with 7zip is a good and simple thing. Why would you need that ? I have a program consisting of an executable and several ressource files as well as configuration which should be easily editable. In my case it’s a modified version of UltraVNC SC. It shall be packed into a single .exe so the costumer has not to mess with a bunch of files.
- Get together your Files
- Grab 7zip console version, 7 zip sfx archieve (in the extra library package)
- Adjust the config.txt
- Adjust this shell code to match your files
7za a -mx=9 -t7z newArchieve.7z File1.exe File2.bat File3.txt
This will make an 7zip archieve (“a” means add files) with the maximum compression level (“-mx=9”) in 7zip format (“-t7z”). You can also use the GUI version of the 7zip packer to do this, it makes no difference. For me the command line is more suitable because i execute this in .bat scripts …
copy /b 7zSD.sfx + config.txt + newArchieve.7z yourFinalExecutable.exe
This commands concats the Files into the final desired executable. The sfx file includes binary code to decompress and execute what you specify in the config.txt file, while the newArchieve obviously holds YOUR files …
Voila there you go. yourFinalExecutable.exe should work on almost any Windows system. Upon it’s execution it will unpack the files in the archieve in a temporary directory, execute the stuff specified in config.txt and after execution remove the archieve files.
Alternativly you can use Paquet Builder
for doing it in a gui. But it’s only allowed for personal use, otherwise you have to pay (which i consider ok as a developer myself).
Replacing the icon of the sfx .exe :
Using Ressource hacker
tip from cashy
This SHOULD work because the icon should be at the same position in your exe, but it COULD possibly DESTROY your exe, so make backup copies first !
reshacker.exe -addoverwrite your.exe, your.exe, yourIcon.ico, icongroup,101,1033
Alternativly Ressource Editor
Useful ressources :
7zip docs -sfx switch
7zip SFX Maker (freeware)
upx –ultrabrute 7zip sfx