Last active
March 19, 2021 04:14
-
-
Save Jaid/407c0f2b01aace1125ea34915ce1f6bb to your computer and use it in GitHub Desktop.
Force administrator permissions in AutoHotkey v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; From https://gist.github.com/Jaid/407c0f2b01aace1125ea34915ce1f6bb | |
| full_command_line := DllCall("GetCommandLine", "str") | |
| if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)")) { | |
| try { | |
| if A_IsCompiled { | |
| Run '*RunAs "' A_ScriptFullPath '" /restart' | |
| } else { | |
| Run '*RunAs "' A_AhkPath '" /restart "' A_ScriptFullPath '"' | |
| } | |
| } | |
| ExitApp | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment