Problem with V2 script when running via Task Scheduler

Get help with using AutoHotkey and its commands and hotkeys
User avatar
JoeWinograd
Posts: 1411
Joined: 10 Feb 2014, 20:00

Problem with V2 script when running via Task Scheduler

10 Aug 2018, 13:37

AHK 2.0-a097-60f26de (64-bit)

I have V1 and V2 on the same W7 Pro 64-bit system. The V1 install is U32, done via the standard installer and, of course, using the AHK file extension for it. My V2 usage is via associating the AHK2 file extension with the V2 AutoHotkeyU64.exe file. The association of AHK2 with the V2 EXE file shows up in Control Panel>Default Programs and it works perfectly when I double-click an AHK2 script in my file manager. But when I put an AHK2 file in the Program/script field in the Action tab of a Task Scheduler job, it fails.

Here's a V2 script that shows the problem:

Code: Select all

fileCurrentVersion:=A_Temp . "\AutoHotkeyCurrentVersion.txt"
urlCurrentVersion:="https://autohotkey.com/download/2.0/version.txt"
Download(urlCurrentVersion,fileCurrentVersion)
MsgBox("Should be running V2","V2 Download")
That works fine when running it from my file manager. But when I put this in the Program/script field of a Task Scheduler job:

D:\temp\v2test.ahk2

I get this:
v2 Task Scheduler failure.png
v2 Task Scheduler failure.png (27.22 KiB) Viewed 828 times
I think what's happening is that it's running V1, not V2, even though the file extension is AHK2.

Interesting to note that it works fine in Task Scheduler if I put this in the Program/script field:

C:\AHKv2\AutoHotkeyU64.exe

And this in the arguments field:

D:\temp\v2test.ahk2

Anyone know why D:\temp\v2test.ahk2 fails in Task Scheduler (apparently calling V1)? Thanks, Joe
User avatar
JoeWinograd
Posts: 1411
Joined: 10 Feb 2014, 20:00

Re: Problem with V2 script when running via Task Scheduler

11 Aug 2018, 18:40

For anyone interested in this issue, I submitted a bug report on it:

V2 script when running via Task Scheduler

Regards, Joe
lexikos
Posts: 6680
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Problem with V2 script when running via Task Scheduler

11 Aug 2018, 20:44

This is most likely due to 8.3 filenames. For instance, the file foo.ahk2 has the 8.3 (short) filename foo~1.ahk. You can verify by running dir /X *.ahk2 at a command prompt, or by running dir *.ahk and noting that .ahk2 files are also returned.
User avatar
JoeWinograd
Posts: 1411
Joined: 10 Feb 2014, 20:00

Re: Problem with V2 script when running via Task Scheduler

11 Aug 2018, 21:52

Hi lexikos,
You are correct on both fronts, i.e., (1) the short filename is v2test~1.ahk and (2) dir *.ahk returns the ahk2 files. I'll switch to ah2 instead of ahk2. Thanks for figuring out this one — much appreciated! Regards, Joe

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Misanthropy and 319 guests