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 AutoHotkey

2. 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 Hacker

Step 1: The Universal AHK Script

This reusable template finds a batch file named `script.bat`, bundles it, and runs it with admin rights.

converter.ahk
#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. 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. 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.

    Ahk2Exe for AutoHotkey v1.1.37.02 -- Script to EXE Converter _ 🗗 X
    File Help
    A
    H
    K

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


    Main Parameters
    Options
    Convert to executable
    Save 'Options' as default
    Ready
  3. 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 Folder
    MyProject/
    │
    ├── 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.

Resource Hacker - [ SystemUtility.exe ] _ 🗗 X
File Edit View Action Help
📂
💾
💾
âœ‚ī¸
📋
📝
🔍
➕
â–ļī¸
â„šī¸
đŸšĢ
  • â–ļ 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)

Replace the default AutoHotkey icon with your own custom logo for a branded, professional appearance.

  1. Open your compiled `.exe` file in Resource Hacker.
  2. Expand the "Icon Group" folder.
  3. Right-click the first item and select "Replace Resource...".
  4. Click "Open file with new icon..." and select your custom `.ico` file.
  5. Click the "Replace" button.
  6. Finally, go to File → Save.

This embeds details like company name and file description into the EXE's properties.

Version Info Script
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.

Manifest XML
<?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.