A self-extracting archive (SFX or SEA) is a computer executable program which contains compressed data in an archive file combined with machine-executable program instructions to extract this information on a compatible operating system and without the necessity for a suitable extractor to be already installed on the target computer. The executable part of the file is known as a decompressor stub.
Self-extracting files are used to share compressed files with a party that may not necessarily have the software to decompress a regular archive. Users can also use self-extracting to distribute their own software. For example, the WinRAR installation program is made using the graphical GUI RAR self-extracting module Default.sfx.
Overview
Self-extracting archives contains an executable file module, a module used to run uncompressed files from compressed files. Such a compressed file does not require an external program to decompress the contents of the self-extracting file, and can run the operation itself. However, file archivers like WinRAR can still treat a self-extracting file as though it is any other type of compressed file. By using a file archiver, users can view or decompress self-extracting files they received without running executable code (for example, if they are concerned about viruses).
A self-extracting archive is extracted and stored on a disk when executed under an operating system that supports it. Many embedded self-extractors support a number of command line arguments, such as specifying the target location or selecting only specific files.
Unlike self-extracting archives, non-self-extracting archives only contain archived files and must be extracted with a program that is compatible with them. While self-extracting archives cannot be extracted under another operating system, they can usually still be opened using a suitable extractor as this tool will disregard the executable part of the file and extract only the archive resource. The self-extracting executable may need to be renamed to contain a file extension associated with the corresponding packer; archive file formats known to support this include ARJ and ZIP. Typically, self-extracting files have a .exe extension, just like any other executable file.
For example, an archive may be called somefiles.zip—it can be opened under any operating system by a suitable archive manager which supports both the file format and compression algorithm used. It may also be converted into somefiles.exe, which will self-extract under Microsoft Windows. It will not self-extract under Linux, but can be opened with a suitable archive manager. Files that are not recognized as archives by archive managers due to their executable extension can be renamed into .zip. This works for ZIP archives due to the way the ZIP header is defined, but not necessarily for other less flexible archive format.
There are several functionally equivalent but incompatible archive file formats, including ZIP, RAR, 7z and many others. Many programs can handle multiple types of archives, whereas others can create, extract, or modify only one type. Additionally, there is a distinction between the file format and the compression algorithm. A single file format, such as 7z, can support multiple different compression algorithms including LZMA, LZMA2, PPMd and BZip2. Decompression utilities must be able to handle both the file format and the algorithm used when expanding self-extracting or standard archives. Depending on the options used to create a self-extracting archive, the executable code placed at the beginning may vary. If you compare a LZMA 7z archive to a LZMA2 7z archive, for example, the decompression routines will differ
Several programs can create self-extracting archives. Among the Windows archivers are WinZip, WinRAR, 7-Zip, WinUHA, KGB Archiver, Make SFX, the built-in IExpress wizard and many others, some experimental. Macintosh users may choose StuffIt, The Unarchiver, or 7z X as their archivers. There are also programs that create self-extracting archives on Unix as shell scripts, which utilize programs like tar and gzip (which must be present in the destination system). Others (like 7-Zip or RAR) can create self-extracting archives as regular executables in ELF format. One of the early examples of self-extracting archives is the Unix shar archive, which combined a number of text files into a shell script that recreated their original content after being executed.