What are SFX Archives?
An SFX archive combines:- A small executable stub (SFX module)
- The compressed archive data
- Optional configuration and GUI
.exe file (Windows) or executable binary (Linux/macOS) that can extract itself.
Creating SFX Archives
Basic SFX Archive
With Custom SFX Module
SFX Module Types
7-Zip includes three SFX modules:1. Console SFX (7zCon.sfx)
Location:CPP/7zip/Bundles/SFXCon/
- Command-line interface
- No GUI dependencies
- Small size (~100 KB)
- Ideal for scripts and automation
2. Windows GUI SFX (7z.sfx)
Location:CPP/7zip/Bundles/SFXWin/
- Graphical interface
- User-friendly extraction dialog
- Size: ~150 KB
- Best for end-user distribution
3. Installer SFX (7zS.sfx)
Location:CPP/7zip/Bundles/SFXSetup/
- Installation wizard interface
- Run commands after extraction
- Set extraction path
- Overwrite prompts
- Best for software installers
SFX Configuration
Create a configuration file to customize SFX behavior:config.txt
Create SFX with Config
Configuration Options
Window title for installer
Message shown before extraction
Show progress dialog (“yes” or “no”)
Program to run after extraction
Default extraction directory
Text in extraction dialog
How to handle existing files
0- Ask user1- Overwrite without prompt2- Skip existing files
Installation path with user prompt
Path Variables
Use special variables in paths:| Variable | Description | Example |
|---|---|---|
%%S | System directory | C:\Windows\System32 |
%%P | Program Files | C:\Program Files |
%%T | Temp directory | C:\Users\...\AppData\Local\Temp |
%%HomeDrive%% | Home drive | C: |
Examples
Software Installer
Silent Extraction
User-Interactive Installer
Creating Multi-Platform SFX
Linux/macOS SFX
Create self-extracting shell archives:sfx_stub.sh
SFX Compression Options
Use maximum compression for SFX archives:SFX Module Source Code
The SFX modules are built from:-
Console SFX:
CPP/7zip/Bundles/SFXCon/- Main file:
SfxCon.cpp - Size: ~100 KB
- No GUI dependencies
- Main file:
-
GUI SFX:
CPP/7zip/Bundles/SFXWin/- Main file:
SfxWin.cpp - Uses Windows Common Controls
- Size: ~150 KB
- Main file:
-
Setup SFX:
CPP/7zip/Bundles/SFXSetup/- Main file:
ExtractCallback.cpp,ExtractEngine.cpp - Full installer functionality
- Size: ~160 KB
- Main file:
Building Custom SFX Modules
You can build custom SFX modules from source:Best Practices
Code Signing
Sign SFX executables to avoid security warnings:Troubleshooting
SFX Won’t Run
- Check compatibility: Ensure SFX module matches target OS
- Antivirus: Whitelist or sign the executable
- Permissions: Run as administrator if needed