Compiled script, needs AutoHotkey.exe?? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
epete
Posts: 81
Joined: 02 Dec 2020, 10:03

Compiled script, needs AutoHotkey.exe??

10 Feb 2021, 08:59

I compiled a script to a .exe, but when I put that on a computer that does not have AutoHotKey.exe; it is asking for it. Doesn't the compile make a self-contained .EXE without the need to have AutoHotKey.exe installed?
Did I do something wrong?
User avatar
gregster
Posts: 9224
Joined: 30 Sep 2013, 06:48

Re: Compiled script, needs AutoHotkey.exe??

10 Feb 2021, 09:01

Sounds like it.
How is it asking for Autohotkey.exe ? :think:
User avatar
epete
Posts: 81
Joined: 02 Dec 2020, 10:03

Re: Compiled script, needs AutoHotkey.exe??

10 Feb 2021, 09:04

When I run, I get
----------------------------------------------
Can't Find:

C:\Program Files\App\AutoHotkey.exe
----------------------------------------------
User avatar
gregster
Posts: 9224
Joined: 30 Sep 2013, 06:48

Re: Compiled script, needs AutoHotkey.exe??

10 Feb 2021, 09:20

Haven't seen that before - try to compile again.

Otherwise you should take a close look at your script - if it's somewhere referencing that path.
Did you use some additional source code protection methods? If yes, which ones? If not, just show your script, or better, a snippet that allows to reproduce the problem.
Did you use special compiler directives?
Which AHK and compiler versions? Windows version?
User avatar
gregster
Posts: 9224
Joined: 30 Sep 2013, 06:48

Re: Compiled script, needs AutoHotkey.exe??

10 Feb 2021, 09:29

I mean, the \App part of C:\Program Files\App\AutoHotkey.exe seems unusual.
That's not even the standard path that the AHK installer would suggest. Is it the path to your AHK program folder on your computer?
User avatar
epete
Posts: 81
Joined: 02 Dec 2020, 10:03

Re: Compiled script, needs AutoHotkey.exe??

10 Feb 2021, 09:54

Thanks folks, I recompiled and now it seems to be working. I did use encryption, but after another compile it seems to have resolved itself. Very odd...
User avatar
gregster
Posts: 9224
Joined: 30 Sep 2013, 06:48

Re: Compiled script, needs AutoHotkey.exe??

10 Feb 2021, 10:15

Was it feiyue's method?
I have never looked into it, but iirc there is something about having autohotkey.exe nearby in order to compile...!?
Or something like that...
User avatar
epete
Posts: 81
Joined: 02 Dec 2020, 10:03

Re: Compiled script, needs AutoHotkey.exe??

10 Feb 2021, 14:50

Ok, I'm back to ask a different question, and I think I know why this wasn't working.

I am trying to use AHK_Encryptor to encrypt my script. Basically because I want to make it a commercial application and don't want people decompiling it with some utility readily available.

What Encryptor does is:
1. embed "AutoHotKey.exe" into the script - that's why it's got to be in the directory of the AHK_Encryptor.ahk script.
2. The encryptor also adds code to "install" AutoHotKey.exe at first execution into the same directory as the application .exe
3. That's because the de-cryption needs AutoHotKey.exe to run.

My procedure has been:
A. Encrypt my script with AHK_Encryptor
B. Compile the encrypted script
C. Run the executable
D. and, the executable goes and installs "AutoHotKey.exe" in the same directory as the compiled .exe

Encryptor needs "AutoHotKey.exe" to de-crypt the encrypted script before it runs.
Now mind you, a compiled script already has AutoHotKey.exe bundled within it, so the script itself doesn't need it - the decryption method seems to need it.
It only seems to create the AutoHotKey.exe on the first run of the encrypted/compliled .exe; because if I delete the AutoHotKey.exe file - it won't get recreated again, and hence I get the error that it can't find "AutoHotKey.exe"

So now my buyer is left with my .exe in the program directory where it got installed, and a "AutoHotKey.exe" in the same directory.

Hence - they can see my .exe is somehow related to AutoHotKey. They may not be able to de-crypt it, but it's a flag I'd like to prevent.

So, if the execution of the .exe DOES NOT extract and install AutoHotKey.exe into the directory the .exe is in (or is deleted by some stance) - you get a message that says "Can't find AutoHotKey.exe". That might happen because of file permissions, etc.

If anyone if familiar with the Encryptor script - or alternative methods to prevent decompiling a complied script - please chime in.
Thanks
User avatar
epete
Posts: 81
Joined: 02 Dec 2020, 10:03

Re: Compiled script, needs AutoHotkey.exe??

10 Feb 2021, 15:29

I think my solution is to not use the Encryptor script - but, rather use mpress.exe to compress the executable. That provides a degree of protection, and actually improves the speed and size of the executable.
TAC109
Posts: 1154
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Compiled script, needs AutoHotkey.exe??

10 Feb 2021, 15:39

If you look at the first few line of the encryptor there is facility for it to change the name of the included AutoHotkey.exe when it is extracted later, so you could make use of this to achieve what you want.

Edit: In particular, see this line

Code: Select all

Ahk=%A_ScriptDir%\AutoHotkey.exe
and the comments a few line above.

For example, to make the extracted AutoHotkey.exe become renamed to abc.exe during extraction, change this line to

Code: Select all

Ahk=%A_ScriptDir%\abc.exe
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
lexikos
Posts: 9780
Joined: 30 Sep 2013, 04:07
Contact:

Re: Compiled script, needs AutoHotkey.exe??  Topic is solved

11 Feb 2021, 04:50

Compiled scripts are not bundled with AutoHotkey.exe by default (except maybe with AutoHotkey_H). A standard compiled script is a copy of AutoHotkeySC.bin which Ahk2Exe has inserted script text into as a "resource". AutoHotkeySC.bin is capable of loading a script only from this "resource", not any other source, hence the need for the "Encryptor" script to include AutoHotkey.exe.

mpress.exe does not improve the speed of script execution. It may or may not improve startup time, depending on whether file I/O is more or less costly than decompression.
w0z
Posts: 230
Joined: 19 Jun 2014, 08:21

Re: Compiled script, needs AutoHotkey.exe??

11 Feb 2021, 18:23

epete wrote:
10 Feb 2021, 15:29
I think my solution is to not use the Encryptor script - but, rather use mpress.exe to compress the executable. That provides a degree of protection, and actually improves the speed and size of the executable.
I was in your situation too. I think I could not use Encryptor but I Finally made it work.

First In the file result after convert to encoded ahk file I changed the lines that is suggested.

Code: Select all

#NoEnv
#NoTrayIcon
#SingleInstance off
SetBatchLines, -1
Ahk=%A_ScriptDir%\ini.exe  ;Ahk=%A_ScriptDir%\AutoHotkey.exe
if (A_IsCompiled)
  FileInstall, ini.exe, %Ahk%    ;FileInstall, AutoHotkey.exe, %Ahk%

s=
s.="u565796926u1555740597u1259231568u2248437892u1075650729u73891"
s.="8535u580988478u244256284u2301702346u65716102u1925456907u3984"
...
After that I made a copy of AutoHotkey.exe and change the name to ini.exe.
Then with ResourceHacker.exe I opened the ini.exe and changed the icons, name , other things That you can see with ResourceHacker.exe.
2021-02-11 17_47_23-sqlite.png
2021-02-11 17_47_23-sqlite.png (3.14 KiB) Viewed 1457 times

So,The result of my project working in a PC that has not autohotkey installed.>
2021-02-11 17_42_09-regfua.png
2021-02-11 17_42_09-regfua.png (12.01 KiB) Viewed 1457 times

I hope it can be helpful for you.
Cheers.
If I was helpful consider Donate me. :beer: , plz :D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AlFlo and 133 guests