SEARCH

How-To Geek

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

Comments (17)

  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

  6. Peterpansen

    thx, the compile soution works great for me!

  7. Windows 7 administrator hack

    Nice article. I am a great fan of your work… All articles over here are just awesome..
    Thanks for your work.

  8. khad

    Thanks, this has solved a dilemma for me. I have a script that is changed frequently but needs admin privs.

  9. Auoro

    thx! i was looking for some solution

  10. TTT05Mikes

    Thanks a bunch for the How-To and the Registry Hack. I’ll give it a try on my new Win 7 64MB Aspire Netbook right now. So glad I don’t have to give up my AHK scripts with my move from XP Pro. Keep on Rock Starring!

  11. PhiLho

    The message by Martin Moltzau is strange (why would I want to install a malware?) and looks like spam. Well, at least it isn’t related to the current topic (bad page?).

    The trick above (registry hack) is useful! I was annoyed to see that the IfWinActive wasn’t working on by shinny new Win7 computer (coming from XP), now it is restored.
    I just have to see how to put my permanent script in the start folder and run it as administrator…
    Mmm, looks like I found out: just right-click on the link, Properties > Advanced > Run as admin… Just have to wait the next restart to see if it works…

  12. Toni

    I am trying to download pictures from my camera to a on-going phto-journal PP presentation at my work, rename the files (I have four within the 118 pictures), but I’m kicked out because there is no program like Picasso or Visio. Although I’m supposed to have Admin. Access, I don’t.
    Really frustrated at this point-have to have the journal done by tomorrow for an ‘Open House’ at HS library. Oh…I’m HS librarian w/o the access. Help me if you can. I follow commands well. Just not too much detail.
    Thanks, Toni

  13. MidActs

    Thank you so much for this How to. I was really worried i would not be able to use AHK if i was running a program as an admin. Your DIY was the best on the web. Thanks again and keep up the good work

  14. français

    hello, I’m a french and i want to say thank you , you are very nice =D !!!

    you were very very very usefull for me !!!

    thank you :p

  15. BuLL

    I got this working by changing the AutoHotKey.exe to always run as administrator (Right-click>Compatibility tab>Run as Admin…).

    So the next time I run my script, it uses the exe but with administrator privileges. I have Win7 ultimate. Not sure if this is available in other versions of Win7/Vista.

  16. KudaFred

    Hie guys, i’m tryin to install the EASEUS Partition Master 7.0.1, onto my machine, hp
    Dv5, but its tellin me, “you must have administrator rights to run easeus Partition Master!”, tryd e regedit but can’t find e autohotkey, n i aint on e net, please help.

  17. Franchesco

    Hello the Geek ! How i use the compile script in my window 7 ? I cannot play games because the admin have password. Can you help me? Add me on Facebook please. Franchesco D. Calonzo in FB

Enter Your Email Here to Get Access for Free:

Go check your email!