Help Starting A Script At System Boot Using RegEdit

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mulsiphix
Posts: 148
Joined: 20 Nov 2015, 17:56

Help Starting A Script At System Boot Using RegEdit

Post by Mulsiphix » 15 Aug 2022, 12:16

Is it possible to start an AHK script using an entry in the Windows 10 Registry? I have no problem starting compiled scripts that are EXE files, but AHK files will not start.

RegEdit Location
[Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
String Value
"location of ahk file"

Example:
"C:\Scripts\test.ahk"
This does not work.


I also tried creating an entry where autohotkey was launched with the script as a parameter. Still, no luck.
String Value
"location of autohotkey" "location of script"

Example: "C:\AutoHotkey\AutoHotkey.exe" "C:\Scripts\test.ahk"

User avatar
mikeyww
Posts: 26880
Joined: 09 Sep 2014, 18:38

Re: Help Starting A Script At System Boot Using RegEdit

Post by mikeyww » 16 Aug 2022, 18:34

It worked here. If your paths are wrong, the command will fail.
Attachments
image001-20220816_cr.png
Registry listing
image001-20220816_cr.png (47.95 KiB) Viewed 400 times

Mulsiphix
Posts: 148
Joined: 20 Nov 2015, 17:56

Re: Help Starting A Script At System Boot Using RegEdit

Post by Mulsiphix » 17 Aug 2022, 09:06

Thank you for responding @mikeyww. There must be something else happening on my end, because it still doesn't work. I copied the AHK startup Registry entry directly into a Windows Command window. It launches the script perfectly, so I know the pathnames are correct. But for whatever reason, it does not launch the AHK when I reboot my system. I don't know :crazy:

This morning I created a workaround for launching the AHK files. The registry is fine with launching EXE files. I update certain AHK files frequently, so recompiling each AHK into a Registry friendly EXE after each script update would be a pain. So, I created a new script to launch AHK files at start. I compiled this script launcher, created a Registry entry for it, and now I won't have to recompile the script launcher unless I need to change which AHK scripts I want starting with the system at boot. It isn't perfect, but it is better than compiling each AHK after and update.

To anyone else who might have a need for it:

Code: Select all

DetectHiddenWindows, On
;Allows you to hide the CMD window. If you won't be hiding your CMD window, then no need to add this line.

SetWorkingDir, C:\Program Files\AutoHotkey\

Run, %ComSpec% /c ""C:\Program Files\AutoHotkey\AutoHotkey.exe" "C:\path_to\script.ahk"",,Hide,

ExitApp

Post Reply

Return to “Ask for Help (v1)”