This is a batch script which calls the AHK Compiler with needed parameters and also changes RC-data using ResHacker. It also needs GoRC.exe.
@echo off setlocal if x%1x==xx goto syntax set ahkpath=C:\PROGRA~1\+Devel\AutoHotkey set ahk2exe=%ahkpath%\Compiler\Ahk2Exe.exe set reshacker=%ahkpath%\Compiler set ahkbin=%ahkpath%\Compiler\AutoHotkeySC.bin set ahkbak=%ahkpath%\Compiler\AutoHotkeySC.bak if not exist %1.ahk goto error set cmdl=%ahk2exe% /in %1.ahk /out %1.exe if exist %1.ico set cmdl=%cmdl% /icon %1.ico if not x%2x==xx set cmdl=%cmdl% /pass %2 set cmdl=%cmdl% /NoDecompile if not exist %1.rc goto skipver echo Making backup of AutoHotkey binary ... if exist "%ahkbak%" ( echo AutoHotkey backup already exists. Do something about it... pause exit ) move "%ahkbin%" "%ahkbak%" echo Compiling Version Information ... ..\GoRC.exe /r %1.rc echo Modifying Version Information ... "%reshacker%\ResHacker.exe" -addoverwrite %ahkbak%, %ahkbin%, %1.res, VersionInfo, 1, echo ****************************************************************************** type "%reshacker%\ResHacker.log" echo ****************************************************************************** :skipver echo Compiling %1 ... %cmdl% echo Compilation done. if exist %1.rc ( echo Restoring AutoHotkey binary ... del "%ahkbin%" move "%ahkbak%" "%ahkbin%" echo Cleaning up ... del %1.res ) goto end :syntax echo Syntax: %0 basename [password] echo. echo basename is the basename of the script WITHOUT extension. echo password may be a password to encrypt the script with before echo compilation. echo. echo NOTE: If there's an .ico file with the same basename, it is used echo as icon for the resulting .exe file. echo If there's an .rc file with the same basename, it is compiled echo and used as version information for the resulting .exe file. echo. pause goto end :error echo Error! Input file does not exist. pause goto end :end endlocal
A RC file looks like this. Actually it's the same, ResHacker shows.
1 VERSIONINFO
FILEVERSION 2,4,0,1
PRODUCTVERSION 2,4,0,1
FILEOS 0x4
FILETYPE 0x1
{
BLOCK "StringFileInfo"
{
BLOCK "040904b0"
{
VALUE "FileDescription", "U3Helper manages registry settings and data files of ordinary applications to make them U3-compatible. (see http://www.u3.com/ for more info)"
VALUE "FileVersion", "2, 4, 0, 1"
VALUE "InternalName", "U3H"
VALUE "LegalCopyright", "(c)2007-2008 Markus Birth <mbirth@webwriters.de>"
VALUE "OriginalFilename", "U3Helper.exe"
VALUE "ProductName", "U3Helper"
VALUE "ProductVersion", "2, 4, 0, 1"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0409 0x04B0
}
}