Add "Run as Administrator" for AutoHotkey Scripts in Windows 7 or Vista

As regular readers know well, I’m a huge fan of using AutoHotkey  to automate my entire computing experience… but in Windows 7 and Vista there’s a serious limitation since you can’t run a script as Administrator by default. This means that your hotkeys can’t interact with windows running in Admin mode… so how do we get around this?

There are three solutions to this problem:

  • Completely Disable UAC – Not the best solution for security purposes, but it works.
  • Compile your script to an executable.
  • Hack the registry and add “Run as Administrator” to the context menu.

Compile Script as Executable

All you have to do is right-click on the script, choose “Compile Script”…

image

And now you can run the executable version as administrator:

image

This isn’t the perfect solution, however. I edit my script all the time, so having to recompile each time I make an edit… would get annoying.

Manual Registry Hack for AutoHotkey “Run as Administrator”

Open up regedit through the start menu search or run box, and then browse down to the following key:

HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell

image

Right-click on “Shell” on the left-hand side and create a new key called “runas”, then create a key called “Command” below it. Then create or set the following two values on the right-hand side, adjusting the path if necessary.

Name Value
(Default) “C:\Program Files\AutoHotkey\AutoHotkey.exe” “%1” %*
IsolatedCommand “C:\Program Files\AutoHotkey\AutoHotkey.exe” “%1” %*

The default key should already be there, just need to set the value.

Now when you right-click on an AutoHotkey script, you’ll see the option to Run as Administrator:

image

Download Registry Hack

Download, extract, and double-click on the AdminAutoHotkey.reg to enter the information into the registry. There’s also a removal script included.

Note that this registry hack will only work if you installed AutoHotkey into the default location, otherwise you’ll have to modify the paths.

Download AdminAutoHotkey Registry Hack

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 03/3/08
More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!