Are you wondering how to compile your old batch scripts into a single package? Why not convert your .bat files to .exe? Converting .bat files to a .exe also lets you secure your script code as it won’t be visible to the naked eye.
In this tutorial, you’ll learn how to convert batch files to executables via built-in and third-party tools.
Let’s start converting!
Table of Contents
Converting BAT file to EXE via IExpress
IExpress is a tool that comes with your Windows OS installation to create stand-alone executables from any script file. But first, let’s create a short batch script to demonstrate how IExpress works to convert a bat script file.
1. Open your favorite text editor, copy/paste the code below and save the file as HelloWorld.bat.
The code below prints the text
Hello world, ATA. The double colons (
::) lets you add a comment in a batch script file.
:: Stops the script from printing out commands as they are executed @ECHO OFF :: Prints out a message on the terminal ECHO Hello world, ATA. :: Waits for a user input before continuing with the rest of the script PAUSE
2. Next, click on the Start button and search for iexpress. Right click on iexpress.exe and choose Run as administrator as you need admin rights to create a system-level executable.
3. On IExpress’ initial page, choose the Create New Self Extraction Directive (SED) option, and click on Next.
A SED instructs Windows to extract a cabinet file or executable ( .DLL or .EXE file) and write it directly to the disk without user intervention.
4. Now, choose the Extract files and run an installation command option on the Package Purpose screen. This option lets Windows extract the contents of the EXE file and run the command inside the EXE file when you run the EXE file.
5. Enter a preferred title for the package and click on the Next button. For this example, the package title is HelloWorld. The package title appears on all prompts the user will see during the installation or execution of the EXE file.
6. Keep the defaults and click on Next on both the Confirmation prompt and the License agreement pages. These options will not affect the installation at all.
When you set a confirmation prompt, Windows asks the user whether to continue with the EXE installation or not. While setting up a license agreement prompts the user to accept the agreement or not upon running the EXE file.
7. Now, click on the Add button in the Packaged files page to select the file you wish to convert and click on Next.
8. Enter the command below to the Install Program field. The
/c argument tells
cmd to run the batch file and then terminate.
cmd /c HelloWord.bat
9. Keep the defaults in the following steps until you get to the Package Name and Options page.
10. Now, click on the Browse button to select a target path, name the EXE file anything you prefer, then click Next. For this example, the EXE file is named HelloWorld.exe.
11. Keep the defaults in the next few steps until you reach the Create package page.
12. Click the Next button on the Create package page to create the EXE file.
13. Finally, navigate to the target you selected in step 10 and run the EXE file (HelloWorld.exe) to see if it works.
Below, you can see the EXE file (HelloWorld.exe) opened a terminal session and printed the Hello world, ATA text.
Converting BAT Scripts to EXE with Bat To Exe Converter
If you’re not into performing tedious steps like IExpress, a popular third-party tool converts .bat to .exe file and is more effective and convenient. Bat To Exe Converter is a free yet handy tool that quickly converts one or several .bat files in a few steps.
1. Open your favorite web browser, download Bat To Exe Converter, and install it.
2. Next, launch the Bat To Exe Converter and click on the Open toolbar button at the window’s top-left corner, and locate the batch file you want to convert (HelloWorld.bat).
3. Click on Convert to provide a name and target location for the EXE file, then click Save to convert your batch file to an EXE file.
4. Finally, run the EXE file and see if it works.
Converting BAT Scripts to EXE via Advanced BAT to EXE Converter
As the name suggests, the Advanced BAT to EXE Converter is the best all-inclusive BAT converter, and it’s free! This tool converts batch scripts to EXE files and batch scripts to MSI, DLL, and VBS files.
1. Download Advanced BAT to EXE Converter, then install it.
2. Next, launch Advanced BAT to EXE Converter and click on the File menu → Open to select the script file to convert to EXE.
3. Now, click on the Build EXE button on the top left. In the Select EXE Options window, click on the Build EXE button, as shown below, to build the EXE file based on the settings you selected.
Perhaps you have dependencies you want to embed on the EXE file. If so, click on the Embed Files tab in the Select EXE Options window and add files to embed.
Now, set a target path and provide a name for your EXE file. Click Save to start converting your batch file to EXE. Below, you can see the conversion progress at the bottom of the window.
Below, you can see the conversion progress at the bottom of the window.
Finally, run the EXE file and see if it works.
In this guide, you’ve discovered that conversion of the batch script to EXE is possible. You’ve learned how to convert a batch script to an EXE file with built-in and third-party tools.
Now would you choose any of the tools in building your project and convert your scripts into executable? Perhaps try embedding multiple dependencies (script files) to your executable file?
More from Adam The Automator & Friends
Expose REST APIs, schedule jobs, and provide custom user interfaces with the platform built for PowerShell to integrate with anything.
We’ve put together a list of the resources we, at ATA, can wholeheartedly recommend!
Why not write on a platform with an existing audience and share your knowledge with the world?