Running as Administrator

Get help with using AutoHotkey and its commands and hotkeys
MikeLondon
Posts: 3
Joined: 30 Jul 2019, 10:22

Running as Administrator

10 Nov 2019, 08:27

This is a schoolboy-level question I'm afraid. I have been using the method below to ensure that a script which is started 'normally' actually runs elevated, as administrator. I had assumed that "#SingleInstance Force" would ensure that the non-admin instance of the script would be terminated before it was re-loaded elevated. However, this doesn't seem to be the case - the code below usually beeps twice.

I can fix this by adding "ExitApp" before the closing bracket. But I am curious why that's necessary.

Code: Select all

#SingleInstance Force
If not A_IsAdmin
{
	Run *RunAs "%A_ScriptFullPath%"               
}					      
SoundBeep
Return
Attachments
Test.ahk
(144 Bytes) Downloaded 8 times

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, DataLife, diegobh00, gignu, MikeyG12, shawnway and 86 guests