What is a batch file?
Before modern operating systems existed, in which we use programs and applications with beautiful and easy-to-use user interfaces, computers were used entering commands directly on a black screen.
Although today most of what we do on a computer we do through a graphical interface, there are still many situations where we need Windows to interpret commands directly. That's why there is the cmd.exe, called Command Prompt.
Il Command Prompt it's a black screen with a simple text box where we can enter commands to run Windows. The most basic commands like ping or ipconfig can be entered manually, but if we have to enter multiple commands one after the other, or we have to use more complicated commands, we need a more complex solution.
That's why batch files exist. A batch file is a text file which contains a series of commands. When we run this file, the command prompt executes all the commands in this file in order.
What is an exe file?
An executable file can do a variety of things. Most of the time, when we use an executable, we want to install an application. When you double click, the installer creates a folder with all the files needed by the application and another exe file that launches it. But executables can also contain an entire application. There are portable programs that can only be run with the exe file.
Any application you have installed on your Windows computer ha probably a main exe file. When you click on the application link, the executable opens and the application starts.
Now, to know how to convert batch file to exe, it is important to know what's inside an exe. We know that a batch file contains lines of code, but an exe is very different.
Within an exe there are different types of data, from code that can be read by the computer, to XML files, data, folders to be copied, Internet access and compressed data, among other things.
How to change the extension of a batch file to.exe?
You can run a batch file by double clicking, so you can usually use them without converting them to other extensions. However, there are situations where you may prefer an.exe file, so we'll show you how to convert it.
Using Windows tools
Since batch files are simple text commands, there is no real way to turn them into an executable. However, it is possible to create an executable that functions like a particular batch file.
On Stackoverflow, user-created code that lets you do just that. You just have to enter the site, copy the code, paste it in the notepad and save the file with the name “Converter.bat”. Then, take the batch file you want to convert and drag it onto the converter.
The code uses a tool that comes bundled with Windows called “IExpress” to compile the batch file and create a new.exe file
Use of external tools
As with any conversion between extensions, there are a multitude of programs and services that let you convert batch to exe easily. On Miracomosehace.com we don't recommend any in particular, but a simple Google search will allow you to find the most popular ones.
Change the icon
When you convert a batch file to exe, the resulting file has a generic Windows icon. To change the icon of an EXE file you have to download a program such as resource hacker, or create a link to the exe file and change the icon using the properties menu.
It is important that all good users know the basics of the files they use on a daily basis. Therefore, we encourage you to keep learning about the batch files and Windows commands you can use with them.