Advertisement
coffeepls

AHK auto-run as admin

Mar 7th, 2023 (edited)
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. full_command_line := DllCall("GetCommandLine", "str")
  2.  
  3. if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
  4. {
  5.     try
  6.     {
  7.         if A_IsCompiled
  8.             Run *RunAs "%A_ScriptFullPath%" /restart
  9.         else
  10.             Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
  11.             ExitApp
  12.     }
  13.    
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement