keepcalculator

06 Numbers and Powers

How to Create SFX Archive with WinRAR and 7-Zip

Card No. 06·62184 · Updated · Standard formula, shown below

Creating a self-extracting (SFX) archive bundles your files into a single executable that unpacks itself when run—no archive program needed on the target machine. This guide walks you through making SFX archives with both WinRAR and 7-Zip, including how to set extraction paths, add icons, and handle common issues.

What You’ll Need

  • WinRAR installed (trial version works) or 7-Zip installed (free, open-source).
  • The files or folders you want to compress.
  • Optional: an icon file (.ico) for the SFX executable, and a text editor for advanced 7-Zip config.

Step-by-Step

Using WinRAR

  1. Select your files in Windows Explorer. Hold Ctrl to pick multiple items or just select a folder.
  2. Right-click the selection, then choose Add to archive… from the context menu.
  3. In the Archive name and parameters window, give the archive a name. Under Archive format, pick RAR (SFX works with both RAR and ZIP, but RAR gives more options).
  4. Check the box Create SFX archive in the Archiving options section. The extension will change to .exe automatically.
  5. Click the Advanced tab, then click the SFX options… button.
  6. In the Advanced SFX options window, go to the General tab. In the Path to extract field, type a destination like %USERPROFILE%\Downloads\MyApp or leave it blank to use the current directory. You can also check Create in the current folder to ignore the path.
  7. Switch to the Setup tab if you want the archive to run a program after extraction (e.g., setup.exe). Type the command in Run after extraction.
  8. Use the Modes tab to control how the SFX behaves: choose Unpack to temporary folder or Install, and set silent mode if you want no prompts.
  9. Click OK on the SFX options, then OK on the main archive window. WinRAR will create the .exe file.

Using 7-Zip

  1. Select your files in Explorer, right-click, and choose 7-Zip > Add to archive….
  2. In the Add to Archive window, set Archive format to 7z (or zip).
  3. Check the box Create SFX archive. The output will be a .exe file. Note: 7-Zip’s built-in SFX module only supports 7z archives, not zip.
  4. Click OK to create the archive. This produces a basic SFX that extracts to the current folder with no options.
  5. For more control (like a custom extraction path or icon), you need to edit the SFX configuration. First, create the archive as above, then right-click the .exe and choose 7-Zip > Open archive to verify contents.
  6. To customize, download the 7zSD.sfx module (usually in the 7-Zip installation folder) and create a text file called config.txt with lines like:
    ;!@Install@!UTF-8!
    Title="My App Installer"
    BeginPrompt="Do you want to install?"
    RunProgram="setup.exe"
    ;!@InstallEnd@!

    Then copy the SFX module and your archive to a folder, and run the command:
    copy /b 7zSD.sfx + config.txt + archive.7z MyInstaller.exe
    from a command prompt.

Common Mistakes

  • Using the wrong archive format: 7-Zip’s SFX only works with .7z archives, not .zip. WinRAR’s SFX works with both but RAR is more feature-rich.
  • Forgetting to set an extraction path: Without it, files unpack to the current directory, which may be temporary or unwritable.
  • Overwriting files without warning: If the user already has files with the same names, they may be overwritten. Use the prompt options to ask before overwriting.
  • Making the SFX too large: Very large self-extracting executables can trigger antivirus warnings or take long to start.
  • Not testing the SFX: Always run the generated .exe on a clean machine to ensure it extracts correctly.

Tips

  • Use a custom icon for a professional look—both tools allow you to specify an .ico file in the SFX options.
  • Set a password in the archive to protect contents, but remember the user will need to enter it during extraction.
  • If you want the SFX to run a program silently, choose “Silent mode” in WinRAR or omit the BeginPrompt line in 7-Zip config.
  • For distribution, consider compressing with maximum compression to reduce download size.
  • Keep a copy of the original archive (non-SFX) for easy updates—you can rebuild the SFX without recompressing.

Troubleshooting

  • Antivirus flags the SFX as a virus: This is common because SFX files can run code. Use a reputable archiver, avoid suspicious prompts, and consider signing the executable if you have a code signing certificate.
  • SFX won’t run on Windows: Ensure the target system supports the architecture (32-bit vs 64-bit) and that you’re not using a very old SFX module.
  • Extraction fails with “Cannot create file”: The user may lack write permissions to the target folder. Suggest they run as administrator or choose a user-writable location.
  • Files extract to the wrong place: Double-check the “Path to extract” setting in WinRAR or the RunProgram path in 7-Zip config. A leading backslash can make it absolute.
  • Custom icon not applied: In WinRAR, you must specify the .ico file in the “Text and icon” tab of SFX options. In 7-Zip, you need to use the Icon parameter in the config file.

Frequently Asked Questions

Can I create an SFX archive with 7-Zip without command line?

Yes, the basic “Create SFX archive” checkbox in the GUI will produce a simple SFX. For advanced options (like custom paths), you need the command-line method described above.

Will an SFX archive work on Mac or Linux?

No, SFX archives are Windows executables. On other systems, users would need a tool like Wine or a cross-platform extractor that can handle the underlying archive format.

Is an SFX archive safe to run?

It’s as safe as the files inside. Since it’s an executable, it can carry malware. Always scan SFX files with antivirus before running, especially if you didn’t create them.

Can I password-protect an SFX archive?

Yes, both WinRAR and 7-Zip allow setting a password on the archive. The user will be prompted for it during extraction.

How do I make the SFX extract to a specific folder?

In WinRAR, set the “Path to extract” field in SFX options. In 7-Zip, use the InstallPath parameter in the config file (e.g., InstallPath="C:\MyApp").

Can I convert an existing archive to SFX?

Yes, you can open the archive in WinRAR or 7-Zip and use the “Add to archive” option again, but it’s easier to recreate the SFX from the original files with the SFX option checked.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →