Wednesday, November 12, 2008

How to create self-extracting 7z archives

Note: This is not an easy task and requires intermediate or advanced knowledge in batch files, parameters, encoding, escape sequences and such computing terms. If you are a beginner, you should create a self-extracting Zip archive, which can be easily done using software such as WinZip.

To successfully create an SFX (self-extracting) archive, you need three parts and a batch program to combine them together. The three parts are:

  • SFX module, the executable code of the SFX archive
  • Configuration file, provides options that control the behavior of the SFX archive.
  • 7z archive, contains the files and folders you want to extract.

Download the required SFX module from Download Links. You would most likely use an LZMA module, which is the default compression method of 7z. The first or second download link should be sufficient, but you must remember to use the module that corresponds to the compression method of your 7z archive. If you are not sure, just use the 7ZSD_All module which is compatible with all compression methods.

Extract the modules into a folder. From now on, we will be working in this folder. Create a configuration file "config.txt" and edit it. The documentation (third link in the download page) provides full-fledged help on what you can include in this configuration file and how to use it. But here's a quick overview. The file should begin and end like this:



Any configuration parameter you wish to include should be between these two lines. There are several parameters that can be included here and I don't wish to go through all of them. You can check the documentation which provides in full detail what they are and how to use them. However the most important parameters are:

InstallPath - an absolute or relative path to which the contents must be extracted. If the path is relative, it will be created in the folder where the SFX archive is.

RunProgram - an application or file in the archive which should be run/opened after the extraction is complete. Do not include the InstallPath value. "nowait:" can be used before the file name to free up memory taken up by the SFX archive after it has extracted.

GUIFlags - controls the user-interaction behavior of the SFX archive. There are several values you can include here as explained in the documentation. For example, if you wish to display the extraction percentage on right (1), display an icon in the extraction window (32), confirm with the user if they click Cancel (256) and replace the question mark with an icon (2048), you should enter the value as "1+32+256+2048" or add them up to "2337"

If you have placed the above three parameters, your configuration file would look similar to this example:


Explore the documentation as there are many more parameters that can be used to add your own messages to the SFX archive, such as licence agreements, instructions, etc.

Once you have prepared the configuration file, place the 7z archive in our working folder. Create an MS-DOS batch file (example, runme.bat) and edit it. The batch file only needs to have one line. Here is an example:

copy /b 7ZSD_LZMA.sfx + config.txt + Archive.7z SFX.exe

7ZSD_LZMA.sfx - This is the SFX module. You may change the name if you are using a different module such as 7ZSD_Deflate or 7ZSD_All.

config.txt - This is the configuration file. You may change the name if your file has a different name.

Archive.7z - This is the 7z archive. Change the name to match your archive.

SFX.exe - This is the file name of the output SFX archive. You may choose any name you like, but keep the ".exe" part.

Please note that the order of the three input files should be maintained. Save and run this batch file and you should see a new EXE file (in example above, SFX.exe), which is the self-extracting archive. Test the SFX archive before deploying.


  1. Thank you, this was extremely helpful. Finally after reading this guide, I managed to crate a successful sfx =)

  2. this was exactly wat i was looking for.
    heavy 7zip archive with progrees bar, cancel button.
    and so small...!!!

    you rock man!!!, i needed it really!!

    you seem to be a really interesting man...

    do tell me more abuot u...

  3. Thank you so much, these few lines are all thats missing from the info provided at.

    Thanks again you made my day!!


Comments are moderated, and are usually posted within 24 hours if approved. You must have a minimum of OpenID to post comments.


Related Posts with Thumbnails