If you have used Visual Studio to create an installer, then you will find that their are two output files required for the installation – setup.exe and setup.msi. You can zip these together into a package, but what if you want a single EXE file installer? Well you can use 7-Zip to create a packaged EXE installer which will then execute your Visual Studio installer all in one go.
First of all, you need a few pre-requisites which are listed below:
- 7-Zip should be installed on the machine you are creating the EXE package with
- You need the “7zS.sfx” file which can be downloaded from our Downloads section
So, you will first need to use 7-Zip to package together your Visual Studio setup files (setup.msi and setup.exe), but instead of compressing them into a zip file, you need to compress them into a 7z file:
You then need to create a “config.txt” file. You should use Notepad++ to create this file and ensure that you are using UTF-8. To do this, click the “Encoding Menu” and choose “Encode in UTF-8”.
Then you need to enter the following into the config.txt file:
;!@Install@!UTF-8!
Title=”Installer v1.0″
BeginPrompt=”Are you sure you want to install Installer v1.0?”
RunProgram=”setup.exe”
;!@InstallEnd@!
You should edit the config.txt to how you require it.
Then create a folder (lets call it C:\package for this guide) and put in the following files:
- config.txt
- package.7z
- 7zS.sfx
You then need to package up the three files to create your EXE in all one installer. To do this, create a text file in “C:\Package” and rename it run.bat – ensuring that you have made the file a batch file and no longer a text file (changing the file extension). Then edit this file and enter the following and save:
copy /b 7zS.sfx + config.txt + package.7z package.exe
Note that the “package.exe” is the filename you want to give to your final installer output.
Once you have done this, you should now find that you have a EXE standalone installer – run it and test it to ensure that everything is how you want it to be.
Frequently Asked Questions
Can I use this for any installer, not just Visual Studio output?
Yes — this technique works for packaging any set of setup files into a single self-extracting EXE, not just Visual Studio installers. As long as your target program has a command-line silent/normal install switch you can reference in RunProgram, the same config.txt and 7-Zip SFX approach applies.
The resulting EXE won’t run — what should I check first?
Double-check that config.txt is saved as UTF-8 (not UTF-8 with BOM, which can break the SFX header parser), that RunProgram exactly matches the filename inside your 7z archive, and that the copy /b command completed without errors — a truncated package.exe is the most common cause of a silently failing installer.
Comments
If you have any comments or questions on this guide, please feel free to leave us a message below using our comments system.
Gear We Recommend
A few general tech accessories worth having alongside this.
Browse our General Tech Accessories picks on AmazonAs an Amazon Associate, TechyGeeksHome earns from qualifying purchases.