Ahk2Exe unable to create destination file

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
JnLlnd
Posts: 487
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada
Contact:

Ahk2Exe unable to create destination file

29 Apr 2020, 23:00

Hi,

I'm using Ahk2Exe regularly but today it fail compiling me script, returning the error: "Error: Error opening the destination file."

I'm using the compiler in command-line mode. I'm creating the exe file on a DropBox folder but had the same error when trying on another drive. There is no disk space issue.

Any idea what could cause this error?

Thanks.
:thumbup: Author of freeware Quick Access Popup, the powerful Windows folders, apps and documents launcher!
:P Now working on Quick Clipboard Editor
:ugeek: The Automator's Courses on AutoHotkey
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Ahk2Exe unable to create destination file

29 Apr 2020, 23:09

I often get problems with file operations (in generals) on dropbox folders, try to pause syncing or use another folder.

Cheers.
TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Ahk2Exe unable to create destination file

29 Apr 2020, 23:16

This error can occur if your antivirus software decides to check the output file while it is being finalised. Also see a similar post here.
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
User avatar
JnLlnd
Posts: 487
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada
Contact:

Re: Ahk2Exe unable to create destination file

29 Apr 2020, 23:19

HI Helgef,

Thanks for the reply. I tried these 2 solutions with the same result.

But I just tried disabling Windows Defender real-time protection and then it worked. So this seems to be a conflict with Windows Defender.

I'd prefer to find a solution in order to be able to compile without having to turn the protection off... Since I'm compiling using a batch file, maybe there is a command line to disable Windows Defender before compiling and re-enable it after... but this is not the forum for this question ;-)
:thumbup: Author of freeware Quick Access Popup, the powerful Windows folders, apps and documents launcher!
:P Now working on Quick Clipboard Editor
:ugeek: The Automator's Courses on AutoHotkey
TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Ahk2Exe unable to create destination file

29 Apr 2020, 23:24

I don’t believe Dropbox will have a bearing on this problem, as the generated file is in the user's %temp% directory at this stage of the compilation process.
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
User avatar
JnLlnd
Posts: 487
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada
Contact:

Re: Ahk2Exe unable to create destination file

29 Apr 2020, 23:25

TAC109 wrote:
29 Apr 2020, 23:16
This error can occur if your antivirus software decides to check the output file while it is being finalised. Also see a similar post here.
Our messages crossed. I was testing it with Windows Defender instead of reading your reply :-)

So, to continue on my previous message, I added a folder exception to the Windows Defender config so I should be OK now.

And thanks TAC109 for the link to the other thread. I should have search better before.
:thumbup: Author of freeware Quick Access Popup, the powerful Windows folders, apps and documents launcher!
:P Now working on Quick Clipboard Editor
:ugeek: The Automator's Courses on AutoHotkey
TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Ahk2Exe unable to create destination file

29 Apr 2020, 23:26

Cheers!
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
TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Ahk2Exe unable to create destination file

30 Apr 2020, 20:57

@JnLlnd
I've published a new version of Ahk2Exe, Beta_9a, that allow a retry in this situation. Would you like to see if it helps?
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
User avatar
JnLlnd
Posts: 487
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada
Contact:

Re: Ahk2Exe unable to create destination file

30 Apr 2020, 22:13

TAC109 wrote:
30 Apr 2020, 20:57
@JnLlnd
I've published a new version of Ahk2Exe, Beta_9a, that allow a retry in this situation. Would you like to see if it helps?
Thanks for doing this. I tested your compiled version with a sample script saved on my Dropbox with Defender enabled and it worked.

However, I must say that the issue I reported yesterday was with an older version of the Ahk2Exe-edge compiler customized for my development pipeline. So, I could not confirm that the new version would work as a replacement of my old version in my custom environment. When I find time to tweak your new version, I'll follow-up here.

Thanks again.
:thumbup: Author of freeware Quick Access Popup, the powerful Windows folders, apps and documents launcher!
:P Now working on Quick Clipboard Editor
:ugeek: The Automator's Courses on AutoHotkey
TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Ahk2Exe unable to create destination file

30 Apr 2020, 23:50

Ahh... If you’re using an older Ahk2Exe-edge version created by fincs, it won’t using your %temp% directory for generating the .exe. In your case Ahk2Exe will be using the Dropbox folder as you indicated before. (This use of %temp% was one of the changes I migrated from Ahk2Exe-master back when I started work on the new version.)

I too, used to get similar errors when I compiled into a Dropbox folder, so the problem may not have been anti-virus related.
Cheers
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
TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Ahk2Exe unable to create destination file

01 May 2020, 01:31

@JnLlnd
Further to my last reply, here is a little script I used to use to run the old Ahk2Exe-edge by fincs. You might find it useful to avoid Dropbox problems. It also provides for new versions of Autohotkey, and new versions of this script.

I had the edge compiler installed in the standard C:\Program Files\AutoHotkey\Compiler\ as Ahk2Exe1.exe.

I had this script called Ahk2Exe.ahk in my source folder.

If I had a new version of this script I would compile it with default parameters so the compiled version was in the source folder. Then I ran the source Ahk2Exe.ahk, which copied Ahk2Exe.exe from the source folder to C:\Program Files\AutoHotkey\Compiler\.

After installing a new version of AutoHotkey, I would again run the source Ahk2Exe.ahk (without compiling first). This would re-set my compiled script to be the official Ahk2Exe.exe

After that, all compiles could proceed normally. All compiles of other scripts could be started by running C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe in any of the standard usual ways.

(Please excuse the quality of the program code! it was early days for me with Ahk.)

Code: Select all

SetWorkingDir %A_ScriptDir%          ; Ensures a consistent starting directory
pf:="c:\Program Files\AutoHotkey\Compiler\"
if !A_IsCompiled
{ IfEqual 0, 0, IfEqual A_IsAdmin, 0, run *RunAs %A_ScriptFullPath%
  IfEqual 0, 0, IfEqual A_IsAdmin, 0, ExitApp
  IfEqual 0, 0, IfExist Ahk2Exe.exe, FileMove Ahk2Exe.exe,%pf%Ahk2Exe.exe.copy,1
  IfEqual 0, 0, FileCopy %pf%Ahk2Exe.exe.copy, %pf%Ahk2Exe.exe, 1
  IfEqual 0, 0, MsgBox 64,, Ahk2Exe has been set up, result=%ErrorLevel%
  IfEqual 0, 0, ExitApp
}
Loop
{ run %pf%Ahk2Exe1.exe %1% "%2%"
  Loop
  { Sleep 500
    IfWinActive Ahk2Exe Error, Error: Error opening the destination file.
    { send {Enter}
      WinWaitClose ahk_exe Ahk2Exe1.exe
      continue 2
    }
    Process Exist, Ahk2Exe1.exe
    IfEqual ErrorLevel, 0, break 2
} }
You wil see that the compiled script monitors for the error, and restarts the compile if it occurs.
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
User avatar
JnLlnd
Posts: 487
Joined: 29 Sep 2013, 21:29
Location: Montreal, Quebec, Canada
Contact:

Re: Ahk2Exe unable to create destination file

01 May 2020, 07:53

Thanks, TAC109. I'll check it.

Jean
:thumbup: Author of freeware Quick Access Popup, the powerful Windows folders, apps and documents launcher!
:P Now working on Quick Clipboard Editor
:ugeek: The Automator's Courses on AutoHotkey

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], DataLife, ShatterCoder and 196 guests