Universal Batch-to-EXE Converter
A complete guide to converting any batch file (.bat) into a single, professional standalone executable (.exe) using free tools.
Prerequisites & Setup
This process requires two free tools. This is a one-time setup to prepare your system.
1. AutoHotkey
The core tool for scripting and compiling. Installing this gives you the `Ahk2Exe` compiler needed to create the base `.exe` file from a script.
Download AutoHotkey2. Resource Hacker
An optional but highly recommended tool for advanced customization, allowing you to add icons, version info, and an admin manifest to your final `.exe`.
Download Resource HackerStep 1: The Universal AHK Script
This reusable template finds a batch file named `script.bat`, bundles it, and runs it with admin rights.
#NoTrayIcon
; This command finds a file named "script.bat" in the same folder
; and bundles it inside the final .exe file.
FileInstall, script.bat, %A_Temp%\run.bat, 1
; This command runs the bundled script with Administrator rights.
; The *RunAs command will trigger a UAC prompt if needed.
Run, *RunAs cmd.exe /k ""%A_Temp%\run.bat""
ExitApp
Pro Tip: For a more professional result where the `.exe` file itself is marked as requiring admin rights, remove `*RunAs` from the script and use the Manifest method in Step 3.
Step 2: The Conversion Process
Follow these steps each time you want to convert a batch file using the Ahk2Exe GUI.
-
1
Prepare Your Files
Take your batch file and rename it to exactly `script.bat`. Place this file in the same folder as your `converter.ahk` script. Here is a useful, menu-driven "System Utility" script you can use:
Example script.bat@echo off setlocal :menu cls echo ==================================== echo System Utility Toolkit echo ==================================== echo. echo [1] Performance Enhancement echo [2] Full Network Reset echo [3] Live Network Connections echo [0] Exit echo. set /p "choice=Enter your choice: " if "%choice%"=="1" goto performance if "%choice%"=="2" goto network if "%choice%"=="3" goto listener if "%choice%"=="0" exit echo Invalid choice. Press any key to return to menu. pause >nul goto menu :performance cls echo [*] Running Performance Enhancement... echo. echo [*] Clearing all user and system temporary files... del /q /f /s %temp%\* >nul 2>&1 del /q /f /s %windir%\temp\* >nul 2>&1 echo Done. echo. echo [*] Clearing Windows Prefetch files... del /q /f /s %windir%\Prefetch\* >nul 2>&1 echo Done. echo. echo [SUCCESS] Performance tasks complete. echo. pause goto menu :network cls echo [WARNING] This will reset your network adapters and echo briefly disconnect you from the internet. echo. set /p "confirm=Proceed with Network Reset? (Y/N): " if /i not "%confirm%"=="Y" goto menu cls echo [*] Running Full Network Reset... echo. echo [*] Flushing DNS cache... ipconfig /flushdns echo. echo [*] Resetting Winsock catalog... netsh winsock reset echo. echo [*] Resetting TCP/IP stack... netsh int ip reset echo. echo [SUCCESS] Network reset complete. A PC restart is recommended. echo. pause goto menu :listener cls echo ==================================== echo Live Network Connections echo ==================================== echo (Refreshes every 5 seconds. Press Ctrl+C to stop) echo. :listener_loop echo Checking connections at %TIME%... netstat -an | find "ESTABLISHED" timeout /t 5 /nobreak >nul cls goto listener_loop
-
2
Open the Compiler
Open your Start Menu and search for `Ahk2Exe` to launch the compiler's graphical user interface (GUI). It will look like the visualization below.
AHKŠ2004-2009 Chris Mallet
Š2008-2011 Steve Gray (Lexikos)
Š2011-2016 fincs
Š2019-2025 TAC109
https://www.autohotkey.com
Note: Compiling does not guarantee source code protection.
Convert to executableSave 'Options' as default -
3
Final Output
After clicking "Convert", you will have a new `.exe` file. You can rename it as you wish. Your project folder will now look like this:
Final Project FolderMyProject/ â âââ SystemUtility.exe <-- Your new application! â âââ converter.ahk (No longer needed for distribution) â âââ script.bat (No longer needed for distribution)
đĄ Where to Find Icons (.ico files)
To give your application a professional look, you can add a custom icon. Here are some free sources:
- Online Converters: Search for "PNG to ICO converter" to turn any image into an icon file.
- Icon Libraries: Websites like `icon-icons.com` or `flaticon.com` offer thousands of free icons. Download the PNG and convert it.
- Windows System Icons: You can extract icons directly from Windows system files (like `shell32.dll` or `imageres.dll`) using Resource Hacker itself.
Step 3: Advanced Customization
Use Resource Hacker to add a professional finish to your compiled `.exe`. This section explains exactly what to click.
- âļ Icon Group
- âļ Version Info
- âļ Manifest
- âļ RCDATA
(Left-hand tree view appears here when you open a file)
(The selected resource code, like the Version Info or Manifest script, will appear here for editing)
A. Changing the Application Icon
Replace the default AutoHotkey icon with your own custom logo for a branded, professional appearance.
- Open your compiled `.exe` file in Resource Hacker.
- In the left-hand tree view, expand the "Icon Group" folder.
- Right-click on the first item inside (e.g., `1 : 1033`) and select "Replace Resource...".
- A new window will appear. Click the "Open file with new icon..." button and select your custom `.ico` file.
- Click the "Replace" button at the bottom of the window.
B. Adding Version Information
This embeds details like company name and file description into the EXE's properties, making it look legitimate and professional.
- From the top menu, click Action â Add from Script Template.
- In the dialog box, select VERSION_INFO from the dropdown and click "Add Resource".
- The code editor will open. Replace its entire content with your version information.
- Click the green "Compile Script" button (looks like a 'Play' icon âļ) in the toolbar above the code.
1 VERSIONINFO
FILEVERSION 3,0,0,0
PRODUCTVERSION 3,0,0,0
{
BLOCK "StringFileInfo"
{ BLOCK "040904B0"
{
VALUE "CompanyName", "Your Company"
VALUE "FileDescription", "My Custom Application"
VALUE "FileVersion", "3.0.0.0"
VALUE "InternalName", "MyApp"
VALUE "LegalCopyright", "Š Your Company. All rights reserved."
VALUE "OriginalFilename", "MyApp.exe"
VALUE "ProductName", "My Application"
VALUE "ProductVersion", "3.0.0.0"
}
}
BLOCK "VarFileInfo"
{ VALUE "Translation", 0x0409, 1200 }
}
C. Forcing "Run as Administrator"
This embeds a manifest into the `.exe` that tells Windows it must be run with administrator privileges. This is more professional than using `*RunAs` in the script.
- From the top menu, click Action â Add using Script Template.
- In the dialog box, select MANIFEST from the dropdown and click "Add Resource".
- The code editor will open. Replace the default text with the XML code below.
- Click the green "Compile Script" button (âļ) in the toolbar.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
D. Self-Signing the Executable
Code signing gives Windows more reason to trust your application, reducing security warnings. This process uses PowerShell to create a certificate and `signtool.exe` to apply it.
Prerequisite: Windows SDK
This process requires `signtool.exe`, which is part of the Windows SDK. You can get it by installing Visual Studio with the "Desktop development with C++" workload.
- Open PowerShell as an Administrator.
- Copy and paste the entire script below into the PowerShell window.
- Important: Before running, you must edit the `$exePath` and `$signtoolPath` variables in the script to match the locations on your computer.
- Press Enter to run the script. It will create certificate files on your desktop, install the certificate, and sign your `.exe`.
# 1. CONFIGURE YOUR DETAILS
$certSubject = "CN=Blindsinner GitHub Phoenix, E=faysaliteng@gmail.com"
$pfxPassword = "YourSecurePassword" # Change this!
$exePath = "C:\Path\To\Your\SystemUtility.exe" # <-- EDIT THIS
$signtoolPath = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\signtool.exe" # <-- EDIT THIS
# 2. CREATE CERTIFICATE
$notAfter = (Get-Date).AddYears(30)
$cert = New-SelfSignedCertificate -Type CodeSigningCert -Subject $certSubject -CertStoreLocation "Cert:\CurrentUser\My" -KeyExportPolicy Exportable -KeySpec Signature -KeyLength 2048 -HashAlgorithm sha256 -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -NotAfter $notAfter
Write-Output "â
Created cert: $($cert.Subject)"
# 3. EXPORT CERTIFICATE FILES
$securePassword = ConvertTo-SecureString -String $pfxPassword -Force -AsPlainText
$pfxPath = "$env:USERPROFILE\Desktop\MyCodeSigningCert.pfx"
$cerPath = "$env:USERPROFILE\Desktop\MyCodeSigningCert.cer"
Export-PfxCertificate -Cert $cert -FilePath $pfxPath -Password $securePassword
Export-Certificate -Cert $cert -FilePath $cerPath
Write-Output "â
Exported PFX and CER to Desktop."
# 4. INSTALL TO TRUSTED ROOT (REQUIRES ADMIN)
Import-Certificate -FilePath $cerPath -CertStoreLocation 'Cert:\LocalMachine\Root'
Write-Output "â
Imported CER to LocalMachine Root Store."
# 5. SIGN THE EXE
$timestampServer = "http://timestamp.sectigo.com"
& "$signtoolPath" sign /f "$pfxPath" /p "$pfxPassword" /tr "$timestampServer" /td sha256 /fd sha256 "$exePath"
Write-Output "â
Signing complete for: $exePath"
# 6. VERIFY SIGNATURE
Get-AuthenticodeSignature -FilePath $exePath | Select-Object -Property Status, SignerCertificate
Write-Output "đ All done! If Status is 'Valid', the signature works."
Important Final Step: Save Your Work!
After you have made any changes in Resource Hacker, you must save them to your `.exe` file. Go to File â Save in the top menu bar, or click the floppy disk icon (đž).
Replace the default AutoHotkey icon with your own custom logo for a branded, professional appearance.
- Open your compiled `.exe` file in Resource Hacker.
- Expand the "Icon Group" folder.
- Right-click the first item and select "Replace Resource...".
- Click "Open file with new icon..." and select your custom `.ico` file.
- Click the "Replace" button.
- Finally, go to File â Save.
This embeds details like company name and file description into the EXE's properties.
1 VERSIONINFO
FILEVERSION 3,0,0,0
PRODUCTVERSION 3,0,0,0
{
BLOCK "StringFileInfo"
{ BLOCK "040904B0"
{
VALUE "CompanyName", "Your Company"
VALUE "FileDescription", "My Custom Application"
VALUE "FileVersion", "3.0.0.0"
}
}
BLOCK "VarFileInfo"
{ VALUE "Translation", 0x0409, 1200 }
}
After pasting the code, click the green "Compile Script" button (âļ), then go to File â Save.
This embeds a manifest into the `.exe` that tells Windows it must be run with administrator privileges.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
After pasting the code, click the green "Compile Script" button (âļ), then go to File â Save.
Code signing gives Windows more reason to trust your application, reducing security warnings. This process uses PowerShell to create a certificate and `signtool.exe` to apply it.
Prerequisite: Windows SDK
This process requires `signtool.exe`, which is part of the Windows SDK.
Open PowerShell as an Administrator and run the full script from the "Self-Signing EXE" tab on a desktop view.