Skip to content

Turn Any File into an EXE with Convert to EXE

converttoexe_logoIf 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.

Download Convert to EXE

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.

convert-to-exe-file-dialog

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

new-exe

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.

convert-to-exe-launch-parameter-dialog

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.

resource-hacker-screen

Then Action > Replace Icon ….

replace-icon-screen

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 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

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.

17 thoughts on “Turn Any File into an EXE with Convert to EXE”

  1. Dear Geeklad, this program of yours seems like what I have been searching. In fact I'm searching for a program that can be make all the files in a folder a one .exe file. I have a folder with a packed powerpoint presentation of one of my lectures. In this folder the powerplugs program places several files. My question is how I can make from all of them one .exe file? The issue is quite signifcant since in the packed program there is still the option to access to the powerpoint slides and some students can make changes to them. Thanks for your kind consideration of this issue and your expert answer.

    1. Unfortunately, in its current state, my program is designed to only convert
      a single file to an exe. That being said, the source code could be modified
      to place several files into the .exe and then launch all of them. I suppose
      the best choice would be to set up the program to execute them in
      alphabetical order.

  2. Geeklad,

    This is a great little app. Is it possible to run this off the command line? I'm using a toll that creates custom context menu entries and I would like to add convert to exe to context menu of bat files. I was thing of writing a batch file to pass the right clicked file to Convert to EXE but no matter how I do it, it opens the /launch dialog.

    Any ideas?

    1. Unfortunately, I created it to be interactive and not to be run 100% at the
      command line. Are you familiar with VBScript? You could always modify the
      source to work exactly how you would like.

  3. Geeklad,

    This is a great little app. Is it possible to run this off the command line? I'm using a toll that creates custom context menu entries and I would like to add convert to exe to context menu of bat files. I was thing of writing a batch file to pass the right clicked file to Convert to EXE but no matter how I do it, it opens the /launch dialog.

    Any ideas?

  4. Unfortunately, I created it to be interactive and not to be run 100% at the

    command line. Are you familiar with VBScript? You could always modify the

    source to work exactly how you would like.

  5. Hi,

    This is great utility. However the problem I faced was the after converting VBS to exe, i had to place VBS in same folder where exe was kept else the exe doesn’t run. Not sure why it happens.

    Can you please let me know of this?

    Thanks

      1. Yes. It does!! Even exe run if vbs is in the same directory. However, as soon as I shift the exe to a separate folder without vbs, it does work. Don’t what is the issues!!!

        1. I’m not sure… It’s been some time since I wrote the program. You may
          want to try looking at the code to see if it might provide any hints as to
          why it isn’t working.

  6. Hi there, i just tested Convert  to EXE, but as soon as i start it a Windows Scrit Host error occurred.

    My OS is Windows Seven x64

  7. http://www.IntellectualPropertyCrossing.com is good medium for job seekers… its a amezing site everyone should try this site … 
    it help us to search job world wide n it is very convienient . In this sit e you did not need to search more just type your qualification and in which city do u want to do job that’s it ……… it is not a advertising website it is just gather all the job seekers n n the employers at one place ….. it helps both the job seeker n also the employer. 
    intellectual property careers

Leave a Reply

Your email address will not be published. Required fields are marked *