-sfx (Create SFX archive) switch
Creates self extracting archive.
Syntax
-sfx[{SFX_Module}]
- {SFX_Module}
-
Specifies the SFX module that will be combined with the archive. This module must be placed in the same directory as the 7z.exe. If {SFX_Module} is not assigned, 7-Zip will use standard console SFX module 7zCon.sfx.
SFX_Module Description 7z.sfx Windows version. 7zCon.sfx Console version. 7zS.sfx Windows version for installers. 7zSD.sfx Windows version for installers (uses MSVCRT.dll).
SFX module can unpack 7z archive or 7z multivolume archive. For example, if you have name.7z or name.7z.001 archive, just rename sfx muldule to name.exe and place to same folder with archive.
SFX modules for installers
SFX modules for installers are included in an external package (7z_extra). You can download these modules from www.7-zip.org. SFX modules for installers (7zS.sfx and 7zSD.sfx) allow you to create your own installation program. Such a module extracts the archive to the user's temp folder, and runs a specified program, and removes the temp files after the program finishes. A self-extracting archive for installers must be created as joining the following files: SFX_Module, Installer_Config (optional), 7z_Archive. You can use the following command to create an installer self-extracting archive:
copy /b 7zS.sfx + config.txt + archive.7z archive.exe
An optimally small installation package size can be achieved, if the installation files are uncompressed before including them in the 7z archive.
-y switch for installer module specifies quiet mode extraction.
Installer Config file format
This config file contains commands for the Installer. The file begins with the string ;!@Install@!UTF-8! and ends with ;!@InstallEnd@!. The file must be written in UTF-8 encoding. The file contains any or all these string pairs:
ID_String="Value"
ID_String | Description |
---|---|
Title | Title for messages |
BeginPrompt | Begin Prompt message |
Progress | Value can be "yes" or "no". Default value is "yes". |
RunProgram | Command for executing. Default value is "setup.exe". Substring %%T will be replaced with path to temporary folder, where files were extracted |
Directory | Directory prefix for "RunProgram". Default value is ".\\" |
ExecuteFile | Name of file for executing |
ExecuteParameters | Parameters for "ExecuteFile" |
You may omit any pair.
There are two ways to run a installation program: RunProgram and ExecuteFile. Use RunProgram, if you want to run a program from the .7z archive. Use ExecuteFile, if you want to open a document from the .7z archive, or if you want to execute a command from Windows.
If you use RunProgram, and if you specify empty directory prefix: Directory="", the system searches for the executable file in the following sequence:
- The directory from which the application (installer) loaded.
- The temporary folder, where files were extracted.
- The Windows system directory.
Config file Examples
;!@Install@!UTF-8! Title="7-Zip 4.00" BeginPrompt="Do you want to install the 7-Zip 4.00?" RunProgram="setup.exe" ;!@InstallEnd@!
;!@Install@!UTF-8! Title="7-Zip 4.00" BeginPrompt="Do you want to install the 7-Zip 4.00?" ExecuteFile="7zip.msi" ;!@InstallEnd@!
;!@Install@!UTF-8! Title="7-Zip 4.01 Update" BeginPrompt="Do you want to install the 7-Zip 4.01 Update?" ExecuteFile="msiexec.exe" ExecuteParameters="/i 7zip.msi REINSTALL=ALL REINSTALLMODE=vomus" ;!@InstallEnd@!
Examples
7z a -sfx a.exe *.txt
adds *.txt files to self extracting archive a.exe using the default console SFX module.
7z a -sfx7z.sfx a.exe *
adds all files to self extracting archive a.exe with module 7z.sfx using windows version of SFX mudule.
Commands that can be used with this switch
a (Add), d (Delete), u (Update),
Other documents on this site:
- 7-Zip Manual /7zC.txt
- 7-Zip Manual /readme.txt
- 7-Zip Manual /copying.txt
- 7-Zip Manual /lzma.txt
- 7-Zip Manual /Methods.txt
- 7-Zip Manual /unRarLicense.txt
- 7-Zip Manual /License.txt
- 7-Zip Manual /src-history.txt
- 7-Zip Manual /7zFormat.txt
- 7-Zip Start Page
- Menu Items and Shortcut Keys
- 7-Zip File Manager
- Benchmark
- Options Dialog Box
- About Dialog Box
- Plugins
- Extract Dialog Box
- 7-Zip Plugin
- Add to Archive Dialog Box
- Exit Codes from 7-Zip
- Command Line Version User's Guide
- Command Line Syntax
- -y (assume Yes on all queries) switch
- -so (write data to stdout) switch
- -ai (Include archive filenames) switch
- -scc (Set charset for console input/output) switch
- -w (set Working directory) switch
- -bb (Set output log level) switch
- -sni (Store NT security information) switch
- -t (set Type of archive) switch
- -ssc (Set Sensitive Case mode) switch
- -ssw (Compress files open for writing) switch
- -stx (Exclude archive type) switch
- -si (read data from stdin) switch
- -sns (Store NTFS alternate Streams) switch
- -spf (Use fully qualified file paths) switch
- -- (Stop switches parsing) switch
- -x (Exclude filenames) switch
- Command Line Switches
- -ax (Exclude archive filenames) switch
- -r (Recurse subdirectories) switch
- -sfx (Create SFX archive) switch
- -i (Include filenames) switch
- -slp (Set Large Pages mode) switch
- -an (Disable parsing of archive_name) switch
- -stl (Set archive timestamp from the most recently modified file) switch
- -sa (set Archive name mode) switch
- -scrc (Set hash function) switch
- -ao (Overwrite mode) switch
- -o (set Output directory) switch
- -u (Update options) switch
- -m (Set compression Method) switch
- -spf (Use fully qualified file paths) switch
- -scs (Set charset for list files) switch
- -p (set Password) switch
- -slt (Show technical information) switch
- -sdel (Delete files after including to archive) switch
- -v (Create Volumes) switch
- d (Delete) command
- rn (Rename) command
- b (Benchmark) command
- l (List contents of archive) command
- e (Extract) command
- Command Line Commands
- a (Add) command
- t (Test integrity of archive) command
- u (Update) command
- h (Hash) command
- x (Extract with full paths) command
- Performance
- Thanks
- Frequently Asked Questions (FAQ)
- 7z Format
- General Information
- License for use and distribution
- Supported formats