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.
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
/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.
/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.
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
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):
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 files
wrapper.vbs: This is a partial VBScript file that is used to launch the file being “converted” to an exe
wrapper.txt: This is the self-extracting archive configuration file for the exes that will be converted
7z.exe: The 7-zip archiving program
7zsd.sfx: The 7-zip self-extracting builder
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
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.