Home » Questions » Computers [ Ask a new question ]

Is it possible to execute a file after extraction from a 7-Zip self-extracting archive (SFX) archive?

Is it possible to execute a file after extraction from a 7-Zip self-extracting archive (SFX) archive?

I'm try to make a compressed deploy-able application.

Asked by: Guest | Views: 194
Total answers/comments: 2
Guest [Entry]

"You will need to download the LMZA SDK from 7-Zip. The ""installer.txt"" file contains documentation:

7zSD.sfx is SFX module for installers. 7zSD.sfx uses msvcrt.dll.

SFX modules for installers allow to create installation program. Such module extracts archive to temp folder and then runs specified program and removes temp files after program finishing. Self-extract archive for installers must be created as joining 3 files: SFX_Module, Installer_Config, 7z_Archive.
Installer_Config is optional file. You can use the following command to create installer self-extract archive:

copy /b 7zSD.sfx + config.txt + archive.7z archive.exe

You need to create a config.txt file.

Config file contains commands for Installer. File begins from string
;!@Install@!UTF-8! and ends with ;!@InstallEnd@!. File must be written
in UTF-8 encoding. File contains string pairs:

ID_String=""Value""

Title Title for messages

BeginPrompt Begin Prompt message

Progress Value can be ""yes"" or ""no"". Default value is ""yes"".

RunProgram Command for executing. Default value is ""setup.exe"". Substring %%T will be replaced with path to temporary folder, where files were extracted

Directory Directory prefix for ""RunProgram"". Default value is "".\""

ExecuteFile Name of file for executing

ExecuteParameters Parameters for ""ExecuteFile""

For example:

;!@Install@!UTF-8!
Title=""7-Zip 4.00""
BeginPrompt=""Do you want to install the 7-Zip 4.00?""
RunProgram=""setup.exe""
;!@InstallEnd@!"
Guest [Entry]

You should also look at NSIS. With it, you can create an installer that is compressed with the same method that 7-Zip uses (LZMA), so it should be roughly the same size, and you have full control over the installation process.