Subject: Windows Executable Packaging, 7-Zip SFX, Automation Deployment
1. Core Concept: SFX Module Types
There are two distinct types of 7-Zip SFX stubs. Mixing them causes failure.
Attribute | Standard SFX | Installer SFX (Correct) |
|---|---|---|
File Name |
|
|
Function | Decompress only | Decompress + Execute |
RunProgram Support | No | Yes |
Typical Failure | Pops up "Extract to" dialog | N/A |
Rule: If the objective is to run a script after extraction,only use7zSD.sfx.
2. Configuration Syntax
The configuration file must be encoded inUTF-8 without BOM.
;!@Install@!UTF-8! Title="Application Name" InstallPath=".\\ " RunProgram="path\\to\\script.bat" ;!@InstallEnd@!Key Parameters:
InstallPath=".\\ ": Extracts to the current directory of the EXE.RunProgram: The command line executed after decompression.
3. Build Procedure (PowerShell)
Binary concatenation is the standard method.
# Create 7z archive & "7za.exe" a -t7z archive.7z @("content_folder") -mx=9 # Concatenate bytes: Stub + Config + Archive [byte[]]$binary = [System.IO.File]::ReadAllBytes("7zSD.sfx") + [System.IO.File]::ReadAllBytes("config.txt") + [System.IO.File]::ReadAllBytes("archive.7z") # Write final executable [System.IO.File]::WriteAllBytes("output.exe", $binary)4. Troubleshooting Matrix
Symptom | Cause | Resolution |
|---|---|---|
"Extract to" dialog appears | Using | Replace with |
Script does not execute |
| Verify Stub is Installer type |
Nothing happens on double click | Corrupted Stub | Use official LZMA SDK binary |
5. Format Constraints
Archive Format: Must be7z.
ZIP Compatibility: Not supported. The
7zSD.sfxdecoder does not recognize ZIP structures.OS Native Extraction: Not supported. Windows Explorer cannot extract this EXE natively.
6. Verification Method
Use a minimal test config:
;!@Install@!UTF-8! RunProgram="cmd.exe" ;!@InstallEnd@!Result: CMD window opens =Valid Stub.
Result: Extract dialog opens =Invalid Stub.