Subscribe to How-To Geek

Recommended: Click Here to Run a Free Scan for Common PC Errors   [Sponsored Link]

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

As regular readers know well, I'm a huge fan of using AutoHotkey  to automate my entire computing experience… but in Windows 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

The Geek is the founder of How-To Geek and a geek enthusiast. When he's not coming up with great how-to articles, he's probably writing at his personal blog. This article was written on 03/3/08 and tagged with: Windows Vista, Vista Tips & Tweaks

Comments (5)

  1. jd2066

    I think as long as the shell key is named "runas" Vista assumes the command in the default value is to be run with Administrator privileges and the "IsolatedCommand" value isn't needed.

  2. The Geek

    I based that registry structure on some existing MS keys…

    I tested and it doesn't seem to be necessary but it's possible it's used somewhere else that I'm unaware of at this point, so I included it for consistency.

  3. jd2066

    Interesting. I based my comment on findings of the HKCR\batfile\shell\runas\command key not having that value and that using a key like that worked for other things like VBS files too.
    It does appear though that other ones like HKCR\exefile\shell\runas\command do have that value.

  4. The Geek

    Yeah, it seems like there's an inconsistency.

  5. martin moltzau

    If You want a free malware & spyware to Your Windows Vista

    1: Go to : Windows Live OneCare Center Beta version for Vista - allow pop-up for this section and select Complete check up

    2: Download: Windows Defender for Windows Vista at Microsoft Download-senter - first You can install Silverlight for Vista and use the new beta-version of the Downloadsenter, it's much quicker!

    3: Download Norton Antibot from Symantec - You can try it for some time for free and scan all your cd's and dvd's - You will be surpriced to find out how many of them that has hidden spy-ware and some have also got malware - If You want to by this - Nab costs about 10$ with one years of updates - that is not very expensive, is it?

    Thank You For A Fantastic & Helpful Website
    I will be back - again & again

    Sincerely Yours: Martin Moltzau


Leave a Comment




Leave your friendly comment here. If you have a computer help question, leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Copyright © 2006-2008 HowToGeek.com. All Rights Reserved.