This article was written by Stan Kats and by wikiHow staff writer, Nicole Levine, MFA. Stan Kats is a Professional Technologist and the COO and Chief Technologist for The STG IT Consulting Group in West Hollywood, California. Stan provides comprehensive technology solutions to businesses through managed IT services, and for individuals through his consumer service business, Stan's Tech Garage. Stan holds a BA in International Relations from The University of Southern California. He began his career working in the Fortune 500 IT world. Stan founded his companies to offer an enterprise-level of expertise for small businesses and individuals.
This article has been fact-checked, ensuring the accuracy of any cited facts and confirming the authority of its sources.
This article has been viewed 436,261 times.
7-Zip is a handy little tool that allows you to compress files into an archive. You can also use 7-Zip to create a self-extracting archive, which is an EXE file that extracts the contained files to a directory when opened. This wikiHow guide will teach you 2 ways to use 7-Zip to create a self-extracting archive in Windows.
Creating Self-Extracting Executables with 7-Zip
- If you want to create a self-extracting executable that prompts the user to extract the files within, you can use the 7-Zip File Manager app on your PC.
- In 7-Zip file manager, select the files you want to include, click +Add, and check the box next to "Create SFX archive."
- If you want your self-extracting executable to run a file, such as an installer or setup file, you'll need to use 7-Zip command line options.
Steps
Creating a Simple Self-Extracting EXE
-
Open 7-Zip File Manager on your PC. If you haven't installed 7-Zip yet, you can get it from 7-Zip's download site.
- If you want to create a self-extracting executable that runs a program instead of just extracting files, jump to Creating a Self-Extracting EXE to Install Software.
-
Select the files you want to add and click Add +. To move up a level in your filesystem, click the icon of a folder with a green up arrow next to the current path. Once you find the folder with the files you want in the archive, hold down Ctrl as you select them, and then click the Add + button at the top.Advertisement
-
Choose the options to create a 7z SFX archive. To do this, select 7z from the "Archive format" menu, then check the box next to "Create SFX archive" in the "Options" area.
- The default file name appears at the top of this window. You can change it if you'd like before you continue.
-
Set any other settings you might need. For example, if you want to compress the archive to an even smaller file size, you can select a different 7z compression option.
- If you want to encrypt the archive with a password, you can select an encryption method and create a password here.[1]
-
Click OK to create the self-extracting archive. This creates an EXE file containing the files you selected. When a user double-clicks the EXE file, the files will be extracted.
Creating a Self-Extracting EXE to Install Software
-
Place all of the files in a single folder. If you want people to be able to double-click the self-extracting archive and have it automatically open an installer or program, you can use this method to create the file. Place the installer or other program file into the directory, along with any other required files.
- To keep things simple, move the files to an easy-to-access location in your main drive, e.g., C:\My_App.
-
Create a 7z file containing the files you want in your self-extracting archive. To do this, you'll need to select all the files in the directory you created, right-click the selection, and choose 7-Zip > Add to Archive. If you're using Windows 11, click Show more options first. This will place the archive in the same directory.
- Call the 7z file something like "Installer.7z".
-
Create a config file. To make sure your self-extracting executable actually runs the contained program, you'll need to create a config file and place it in the directory containing the executable and 7z file. Open Notepad or your preferred text editor, then create a config file that looks something like this:[2]
;!@Install@!UTF-8! Title="My App 4.00" BeginPrompt="Do you want to install My App 4.00?" RunProgram="setup.exe" ;!@InstallEnd@!
- Replace "setup.exe" with the name of the executable you want to launch if the user agrees.
- See this MIT page for more config file examples.
- Save this file in the same directory as the files you're including in the executable, and call it config.txt.[3]
-
Download the LZMA SDK from 7-Zip. To download it directly from the 7-Zip website, go to the download page and click the Download link next to "LZMA SDK: (C, C++, C#, Java)". Once downloaded, extract the files inside.
- To keep things simple, move the extracted directory to the root of your main drive. E.g., C:\lzma2600.
-
Add the LMZA directory to your system path. Here's how:
- Type environment variables into the Windows search bar.
- Click Edit the system environment variables.
- Click the Environment Variables button.
- In the "User variables" section at the top, select Path and click Edit.
- Click New and enter the path to the LZMA folder you extracted. For example, C:\lzma2600.
- Click OK, then OK again.
- Click Apply.
-
Open a Command Prompt window. To do this, type cmd into the Windows search bar, then click Command Prompt.
-
Create the self-extracting executable. Here's how:
- First, cd into the directory containing the files you want to include in the self-extracting executable. E.g., cd C:\My_App.
- Run this command, but replace "Installer.7z" with the name of the file you created, and "MyInstaller.exe" with the name you want to give the self-extracting executable: copy /b 7zSD.sfx + config.txt + Installer.7z MyInstaller.exe
- Now, when you double-click your new self-extracting executable, it will run as expected.[4]
Video
Community Q&A
-
QuestionHow do I use a specific path automatically?
Community AnswerUsing 7Zip, you can't. There are a lot of other archiving programs (such as WinRAR) that can do it, but I would recommend that you just tell people to extract it to the specified directory as it's a much simpler interface.
Tips
-
Don't open an .exe if you are not sure of its origin.Thanks
-
Use anti-virus software to protect your computer from malicious software, and to scan the files prior to putting them in the archive.Thanks
References
- ↑ https://cloud.wikis.utexas.edu/wiki/spaces/coeito/pages/76220003/How+To+Create+a+Self-Extracting+Encrypted+Archive+File+With+7-Zip
- ↑ https://web.mit.edu/outland/arch/i386_deb50/build/p7zip_4.44/DOCS/MANUAL/switches/sfx.htm
- ↑ http://ntsblog.homedev.com.au/index.php/2015/05/14/self-extracting-archive-runs-setup-exe-7zip-sfx-switch/
- ↑ http://ntsblog.homedev.com.au/index.php/2015/05/14/self-extracting-archive-runs-setup-exe-7zip-sfx-switch
About This Article
Reader Success Stories
-
"I had to change compression method from "BZip2" to enable the Create SFX Archive check box. Thanks for the article!"..." more













