Skip to content

Instantly share code, notes, and snippets.

@suewonjp
Created January 10, 2017 03:51
Show Gist options
  • Save suewonjp/072623f6fecf3ccd3bf3b962681c1adc to your computer and use it in GitHub Desktop.
Save suewonjp/072623f6fecf3ccd3bf3b962681c1adc to your computer and use it in GitHub Desktop.
Converting .bat to .exe using AutoIt

There are many ways to convert Windows batch script files to .exe files;

Unfortunately, most of hit methods when searching with https://www.google.co.kr/?gws_rd=ssl#newwindow=1&q=bat+to+exe
may not work or may not satisfy your quality demand;

Many of these naive implementations may let most of antivirus apps consider your result .exe file as a malware;

I tested several tools but until now, AutoIt is the best tool to convert .bat to .exe

Workflow:

  1. Install AutoIt from its site
  2. Edit an .au3 script file to call your .bat script
  1. Compile it to .exe
### This script is actually used for Civilizer (https://github.com/suewonjp/civilizer),
### the open source personal knowledge management/note taking application
#pragma compile(AutoItExecuteAllowed, True)
#include <Constants.au3>
Local $pid = Run(@ComSpec & " /c " & 'where java', "", @SW_HIDE)
If $pid == 0 Then
MsgBox($MB_SYSTEMMODAL, "civilizer-win32.exe ERROR", "Can't find JRE (Java Runtime Environment)!" & chr(13) & chr(10) & "Download and install JRE from Oracle unless you haven't")
EndIf
Run("run-civilizer.bat", "", @SW_HIDE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment