I wanted an AutoHotKey script to start as Admin at boot and avoid UAC prompt.
It is a v1 script.
Create a task & a shortcut to the task & place the shortcut in shell:startup.
Task Scheduler
Steps:
1. Open Task Scheduler -+ Create Task
2. Give it a name, e.g. GeorgeAHK
3. Check "Run with highest privileges"
4. On the Actions tab + New:
o Program: path to AutoHotkey.exe "C:\Program Files\AutoHotkey\AutoHotkey.exe"
o Arguments: path to your .ahk file C:\Users\George\Documents\George.ahk
5. Save
Create Shortcut and place in Start
C:\Windows\System32\schtasks.exe /run /tn "GeorgeAHK"
Why I wanted to do this:
In my script of hotkeys is "cntl + space" which pins an app to top.
It did not work on programs running as elevated admin.
I did first try elevating the script.
It worked but it asks for UAC approval when launched.
#Requires AutoHotkey v1.1
; --- Auto-elevate ---
if !A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%", , UseShellExecute
ExitApp
}
; ---------------------
^Space::