LOGO

Run AutoHotkey Scripts as Administrator - Windows 7 & Vista

March 3, 2008
Run AutoHotkey Scripts as Administrator - Windows 7 & Vista

Automating Tasks with AutoHotkey and Administrator Privileges

For those familiar with automating computing tasks, AutoHotkey is a powerful tool. However, users of Windows 7 and Vista encounter a limitation: scripts cannot, by default, execute with administrator privileges.

This restriction prevents hotkeys from interacting with applications running in administrator mode. Fortunately, several workarounds exist to overcome this challenge.

Solutions for Running AutoHotkey Scripts as Administrator

There are three primary methods to enable AutoHotkey scripts to function with elevated permissions:

  • Compile Script as Executable
  • Manual Registry Hack
  • Download Registry Hack

Let's examine each approach in detail.

Compiling Scripts for Administrator Access

The simplest solution involves compiling the AutoHotkey script into an executable file. To do this, simply right-click the script file and select "Compile Script".

The resulting executable can then be launched with administrator privileges.

add-run-as-administrator-for-autohotkey-scripts-in-windows-vista-1.jpg

While effective, this method isn't ideal for frequent script editing. Recompiling the script after each modification can become tedious.

Implementing a Manual Registry Adjustment

A more permanent solution involves a direct modification to the Windows Registry. Open the Registry Editor (regedit) via the Start Menu search or Run dialog.

Navigate to the following key:

HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell

add-run-as-administrator-for-autohotkey-scripts-in-windows-vista-2.jpg

Right-click on "Shell" and create a new key named "runas". Under "runas", create another key called "Command".

Within the "Command" key, create or modify the following two values, adjusting the path if your AutoHotkey installation differs:

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

The default value should already exist; simply update it if necessary. After this change, right-clicking an AutoHotkey script will present the option to "Run as Administrator".

add-run-as-administrator-for-autohotkey-scripts-in-windows-vista-3.jpg

Utilizing a Pre-Made Registry Hack

For convenience, a pre-configured registry hack is available. Download, extract, and double-click the "AdminAutoHotkey.reg" file to import the necessary settings into the registry.

A removal script is also included for reverting the changes. Note that this hack is designed for standard AutoHotkey installations; modifications to the paths may be required if you installed AutoHotkey in a non-default location.

Download AdminAutoHotkey Registry Hack

#AutoHotkey#administrator#Windows 7#Windows Vista#script#run as administrator