Windows Compression – Execute File After Extraction from 7-Zip SFX Archive

7-zipcompressionwindows

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

Currently I'm taking a set of files that I've published from my IDE (Visual Studio 2008 – WPF published application) and compressing them in a 7-Zip SFX archive.

My users have asked if they can "one click install" from the 7-Zip exe. There is a parameter list when I'm creating the archive. Is there a way to set some sort of combination of parameters to invoke the installer executable that is extracted?

Unfortunately the 7-Zip documentation doesn't seem to cover this scenario. I've seen several paid applications that do something similar to this, but I'm trying to keep the tool that I'm writing free of licensed code so that we can use it internally.

Best Answer

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@!
Related Question