How To Guides Org

Learn Autohotkey Part 3: Run Autohotkey Scripts As Admin To Avoid UAC Prompts When Running Scripts

If you are using Autohotkey to write scripts for Windows 7 and you are annoyed that you are still prompted by UAC for elevated rights then here’s the solution.


Previous parts:
Part 1 What Is Autohotkey

Part 2 Assign String To Keyboard Button

Compiling AHK

1. Step Go to your AHK script file and right click on it, then select Compile

2. Step As you can see in the picture, a green “idletimelaunch.exe” will appear.

3. Step Right-click on the .exe file and click on Properties

4. Step Go to the tab Compatibility and at the bottom check the box Run this program as an administrator (Privilege Level)

5. Step Hit Apply and you can now execute this .exe file and all commands that you are running in your AHK script will be executed with admin privileges

EXAMPLE: How to run bat file with admin privileges:

Let’s say you wanted to run a batch file with admin rights e.g. a backup batch that requires elevated rights. Normally AHK would throw out a UAC prompt when you add this code:

Run C:\Users\sOliver\Documents\Useful.bat

However, when you compile the script and check the box Run as admin as described above it will work just fine. Just perfect for an unattended backup batch file.

I hope this will help some of the AutoHotkey newbies out there.