A self-extracting archive (SFX) is a computer executable program which contains data in an archive file combined with machine-executable program instructions to extract this information. On executing the program under an operating system which supports it, the archive contents are extracted. Non-self-extracting archives contain the data files only, which need to be extracted with a compatible program. Self-extracting archives cannot self-extract under a different operating system, but can be opened with a suitable program. For example, an archive may be called SOMEFILES.ZIP; it can be opened under any operating system by a suitable archive manager. It can be converted into SOMEFILES.EXE, which will self-extract on a machine running Microsoft Windows. It will not self-extract under Linux, but can be opened with the Linux unzip tool.
There are several functionally equivalent but incompatible archive file formats, including ZIP, RAR, 7z, and many others. Some programs can manage (create, extract, etc.) one type of archive; many programs can handle multiple formats.
Several programs can create self-extracting archives. For Windows there are WinZip, WinRAR, 7-Zip, WinUHA, KGB Archiver, the built-in IExpress wizard and many other experimental ones. For Macintosh there are StuffIt, The Unarchiver, and 7zX. There are also programs that create self-extracting archives on Unix as shell scripts which utilizes programs like tar and gzip (which must be present in destination system). Others (like 7-Zip or RAR) can create self-extracting archives as regular executables in ELF format. An early example of a self-extracting archive was the Unix shar archive, in which one or more text files were combined into a shell script that when executed recreated the original files.
Archiving files rather than sending them separately allows several, often related, files to be combined into a single one; reduces the size of files not already efficiently compressed (e.g., it will reduce the size of a word processor document, but hardly affect a JPEG picture); and for many formats allows files to be encrypted for security. SFX archives extend the advantages of archives to users who do not have a program to extract the contents of archives, but are running a compatible operating system. For users who do have archive managing software, an SFX may still be slightly more convenient.
A disadvantage of self-extracting archives is that running executables of unverified reliability, e.g., sent as email attachments or downloaded from the Internet, is a security risk: an executable file described as an SFX may actually be a malicious program. The protection against this is to open it with an archive manager instead of executing it (losing the minor advantage of self-extraction); the archive manager will report if the file is not an archive.
Some systems for distributing files do not allow executable files to be distributed, to prevent the sending of malicious programs; this disallows SFX files, unless they are cumbersomely renamed by the sender to, say, SOMEFILES.EXX, and renamed back again by the recipient.
Self-extracting archives will only run under the operating system with which they are compatible. They must include code to self-extract, making them a little larger than the original archive.
- Kolmogorov complexity, a theoretical lower bound on the size of a self-extracting archive