5

So I have two scripts in shell:startup. One that is a bunch of hotkeys to do various things when I push ctrl+c/a/s/etc. and the other is meant to run something once at boot up and that's it.

The problem is that the on boot script is not working. Nothing happens from it on power on.

If I run the script manually it does work as intended. I tried adding a sleep as I thought maybe it was running before some required stuff was loaded, but still no luck, even with a 10 minute delay. The script never does anything, it is never shown in the taskbar.

What is the problem?

I can provide the script if necessary, but since it doesn't look like it loads at all I don't think its a coding problem.

7
  • Try this: Copy and paste the non-running script into the .ahk file of the one that does run. If it still doesn't run you know it has something to do with the script. If it starts working, there's an issue with how you're starting that particular script. Jan 3, 2018 at 13:10
  • 1
    Something else you can try for debugging is to create a rule in Task Manager to run on startup or on user login or something of that nature, in which case Task Manager will definitively tell you whether the program executed (and when), for the rule you created. As with the suggestion above, this is primarily useful to help delineate whether the problem is related to starting the script vs. having the script execute. Tasks can also be executed manually once they are created.
    – JJohnston2
    Jan 4, 2018 at 2:53
  • @TwistyImpersonator I copied the entirety of the script that wasn't working into the top of the one that was working, and on boot, the non working script did work as intended. So I'm not sure what's going on, is there perhaps a problem with opening multiple scripts on boot?
    – Aequitas
    Jan 4, 2018 at 22:21
  • No, I have 3 that load on login and they work fine. Try @techturtle's answer. That's how I have my scripts configured, though not because they need admin rights. Jan 4, 2018 at 23:49
  • The solution works for me: autohotkey.com/boards/viewtopic.php?t=15820
    – preachers
    May 4, 2019 at 3:25

3 Answers 3

4

Not sure if you had this running in anything prior to Windows 10, but when I upgraded from Windows 7 I found that some of my AutoHotKey scripts stopped working on load. I finally figured out it was because they now needed admin rights (I don't think they needed them in Win7), but Win10 blocks the items in the shell:startup and shell:common startup locations from running as admin.

My solution is a little convoluted but works well. Basically, I left my script in a normal (non-startup) location, such as C:\Users\xyz\Documents and then created a shortcut to the script in that same location. You can then set the properties of the shortcut to run as admin. Finally, in the shell:startup location, I created a batch file that would autorun and call the shortcut:

start "MyScript" /D "C:\Users\xyz\Documents\" /B MyScript.ahk.lnk
1
  • I don't think this would be the case since the other script opens up just fine.
    – Aequitas
    Jan 4, 2018 at 22:19
4

I had same problem in win10, the solution is to edit the startup registry directly.

  1. run regedit
  2. browse to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  3. Add new String Value
  4. For Value Data, input path to your .ahk file

That's it.

0

I found another solution which may seem better that previous.

When I started to use AHK I created all .ahk files in one folder. However, I think, everyone does so. In this case it is very easy to run all these files with bat file. It like like this:

@echo off
cd f:/hotkeys
for /f  %%f in ('dir /b /s .') do start %%f

Create a file with such content and put it in startup directory: Win+R > shell:startup. That's it.

The script was taken from here https://stackoverflow.com/questions/180741/how-to-do-something-to-each-file-in-a-directory-with-a-batch-script/180749#180749.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .