Skip to main content

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 Solta.ru 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:

;!@Install@!UTF-8!

;!@InstallEnd@!

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:

;!@Install@!UTF-8!
InstallPath="ExtractFolder"
RunProgram="nowait:setup.exe"
GUIFlags="1+32+256+2048"
;!@InstallEnd@!

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.

Comments

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

    ReplyDelete
  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...

    ReplyDelete
  3. Thank you so much, these few lines are all thats missing from the info provided at.
    http://7zsfx.solta.ru/en/

    Thanks again you made my day!!
    Dec

    ReplyDelete

Post a Comment

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

Popular posts from this blog

Disable auto save in JetBrains IDE software (IntelliJ IDEA, PyCharm, PhpStorm)

JetBrains provides the following IDE software:
IntelliJ IDEAPhpStormPyCharmRubyMineWebStormAppCodeCLion Google also provides Android Studio which is powered by the IntelliJ platform.

If you come from a different IDE such as Eclipse, you will be unpleasantly surprised to find that JetBrains-branded IDEs automatically save everything the moment you look away. The proponents argue that as you work on your project, you should not have to worry about saving files. But to others, this auto-save behavior which is enabled by default is a curse that catches them by surprise, and a shocking departure from the workflow they are very much used to.

You can change the behavior by altering some settings.

Stop having to click Unblock on every downloaded file

CAUTION: The blocking of downloaded files in Windows is a security and safety feature to help prevent your computer from being infected by viruses and other malware. Only disable this feature if you know what you're doing.

I had been plagued by this annoyance since the days of Windows Vista. Any downloaded file, no matter what browser I use, gets tagged as "blocked" by Windows. You can open downloaded documents even though they are blocked, but when you run a downloaded application (such as a setup file) you're presented with a "Security Warning" before you're allowed to run it. It's worse if you extract a downloaded ZIP file with the Windows' built-in ZIP management. Every extracted file is blocked by default.

Being a geek who finds unnecessary "security" prompts annoying, the first thing I do in Windows is to disable the User Account Control (UAC). But I couldn't quite figure out how to disable blocking of downloaded files until …

Install Windows 10 Tech Preview when setup says media driver missing

Skip to the end for instructions.
I had been trying to install Windows 10 Pro Technical Preview onto a VHD, as I have Windows 7 Ultimate and can run an operating system from VHD (this feature is apparently limited to Enterprise and Ultimate editions).

While I had successfully managed to install it on a virtual machine in Oracle VirtualBox, I was dissatisfied with the sluggish performance of a VM. At the same time, I also did not want to dedicate a real hard disk partition for the sole purpose of installing Windows 10 TP.

Hence the decision to install into a VHD, which is a very neat solution that lets me keep Windows 10 TP separate from my real hard disk partitions and still enjoy the full native speeds of my real hardware. I had previously installed Windows 8 RC successfully into a VHD so I knew what I was up against.

Or so I thought. As soon as I booted up the setup disk (the ISO I had downloaded) and clicked on Install Now, I received this very unhelpful error asking for device dri…