Turn Any File into an EXE with Convert to EXE
If you’re a geek like me, you may on occasion have run into a situation where you had a file that you needed to convert to exe. I had read a few forum posts and tutorials on how to do this with self-extracting installers, and I even managed to do it with a 7-zip tool called 7zSD. It then dawned on me that I could use 7zSD and some VBScript to create a tool to automate it. Thus, my Convert to EXE tool was born.
Initially, I wanted just to convert a VBScript into an executable file. The reason I wanted to do this was to add a Java application to geek.menu (a fork of the PortableApps.com Suite). I then realized that it might be useful to expand the tool to convert batch files to exe, or any other kind of file for that matter. So I did just that.
Usage
It’s pretty stupid-simple to use. Just launch the exe, navigate to the file you want to convert to an EXE and select it.

The tool will create an exe file in the same directory where the file you are converting to exe is located.

If you are converting a batch file to exe (or some other console program), you’ll be pleased to know that the exe file the tool generates never displays the command line window. There is one command line parameter you can use when launching converttoexe.exe: /launch
/launch allows you to just specify a command you want to place into an exe. First, run converttoexe.exe /launch (you can do this from the Run… command in your Windows Start menu). It will first prompt you for the command you want to run. Be sure to place quotes if the filename and/or path contains spaces, so that it will launch properly.

After you provide the command, you’ll be prompted for the name and location of the exe file it will create. Navigate to where you want to save the new exe and click Open. The new exe will be saved there with the name you selected.
The /launch feature is good to use if you have a program that needs to be launched with specific command line parameters. A good example is if you have a java application or something, where it needs to be launched with javaw.exe and then a bunch of parameters after it.
The PortableApps.com suite and geek.menu only recognize exe files for the launch menu. This makes Convert to EXE ideal for placing Java applications into them. Even better is the fact that they are launched without ever displaying the command window. It is one of the easier and elegant solutions you’ll find for adding a Java application to the PortableApps.com suite.
Changing the Icon of the EXE File
If you want to change the icon of the output exe file, you can use a nice little tool called Resource Hacker. Just open the exe in resource hacker, and navigate to Icon Group > 101 > 0.

Then Action > Replace Icon ….
![]()
Click Open file with new icon…, navigate to the location with the icon and click Open. Click the Replace button. Finally, click File > Save. This is exactly what I did to change the icon for converttoexe.exe.
Technical Details and Source Code
I built the application in very much the same way in which it builds other exe files. There is a main VBScript (converttoexe.vbs) and a partial script used as a wrapper (wrapper.vbs) to execute the desired file. Essentially what the tool does is create a self-extracting 7-zip archive, and uses some VBScript as a wrapper to launch the file. It does nothing more than create a self-extracting archive that launches the file that is compressed into it.
If you’re interested in looking at the code and modifying it, I’ve made it available as well (under the GPL):
Download the Convert to EXE Source Code
To “compile” it, just run build.bat. It doesn’t really compile anything, it just builds a self-extracting archive containing several files:
converttoexe.vbs: This is the file containing most of the VBScript code to generate the exe fileswrapper.vbs: This is a partial VBScript file that is used to launch the file being “converted” to an exewrapper.txt: This is the self-extracting archive configuration file for the exes that will be converted7z.exe: The 7-zip archiving program7zsd.sfx: The 7-zip self-extracting builder
The build.bat file is pretty straight forward and easy to follow. It creates a 7-zip archive file called converttoexe.7z that contains all the files that are necessary to build other exe files. The only line that looks a little weird is the line that actually builds the exe:
copy /y /b 7zsd.sfx + build.txt + converttoexe.7z converttoexe.exe
It combines the 7zsd.sfx file, build.txt file (the configuration file for the self-extracting archive), and the converttoexe.7z archive that contains all the magic necessary to build other exe files. Feel free to let me know if you make any modifications/enhancements to the scripts. I can update the downloads here.
Related Posts
- Update to Google Webmaster Tools Greasemonkey Script
- Useful Applications on the Go
- My Three Goals for 2009
Related Websites
- Boost Your Income with Blog Secrets
- The Case of the Unexplained, 2010: Troubleshooting with Mark Russinovich (TechEd 2010)
- Optimize your layouts
Comments
-
Kingsmob77
-
GeekLad
-
George
-
GeekLad
