# -sfx (Create SFX archive) switch

Creates self extracting archive.

#### Syntax

    -sfx[{SFX_Module}]

{SFX_Module}

  Specifies the SFX module that will be added to 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.
  7zC.sfx | Compressed windows version .
  7zCon.sfx | Console version.
  7zS.sfx | Windows version for installers.
  7zSD.sfx | Windows version for installers (uses MSVCRT.dll).

The most of SFX modules (except 7zC.sfx) are uncompressed. You can use UPX program (http://upx.sourceforge.net) to compresss such modules. After compressing by UPX program size of sfx module will be reduced to 40-50% of original size.

#### SFX modules for installers

SFX modules for installers are included in external package (7z_extra). You can download these modules from www.7-zip.org. SFX modules for installers (7zS.sfx and 7zSD.sfx) allow to create installation program. Such module extracts archive to temp folder and then runs specified program and removes temp files after program finishing. Self-extract archive for installers must be created as joining 3 files: SFX_Module, Installer_Config, 7z_Archive. Installer_Config is optional file. You can use the following command to create installer self-extract archive:

    copy /b 7zS.sfx + config.txt + archive.7z archive.exe

The smallest installation package size can be achivied, if installation files was uncompressed before including to 7z archive.

-y switch for installer module specifies quiet mode for extracting.

#### Installer Config file format

Config file contains commands for Installer. File begins from string ;!@Install@!UTF-8! and ends with ;!@InstallEnd@!. File must be written in UTF-8 encoding. File contains string pairs:

ID_String="Value"

ID_String | Description
--- | ---
Title | Title for messages.
BeginPrompt | Begin Prompt message.
RunProgram | Command for executing. substring %%T will be replaced with path to temporary folder, where files were extracted

You can omit any values.

#### Config file Examples

    ;!@Install@!UTF-8!
    Title="7-Zip 2.30"
    BeginPrompt="Do you want to install the 7-Zip 2.30?"
    RunProgram="Setup.exe /T:%%T"
    ;!@InstallEnd@!

Program will Prompt with BeginPrompt message, and then run command RunProgram. That simple installer is based on .inf file. and it uses advpack.dll.

#### 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),