0

i need some help..

does anyone know about "elevate" thingy in autohotkey? So i'm just messed up because now my script can't run properly after reinstalling new windows. Now my script cannot process COM / Macros commands for Excel automation..

Before, it was able to activate sheet, activate window, etc. But now it can't.

Can somebody help me with this? Thank you very much

Ram
  • 11
  • 3
  • Does this answer your question? [How to add administrator privileges to AutoHotkey script?](https://stackoverflow.com/questions/43298908/how-to-add-administrator-privileges-to-autohotkey-script) – Spyre Apr 03 '21 at 22:35

1 Answers1

0

Here is a script that will request to elevate itself if it is not run elevated:

MsgBox, % "I am" (A_IsAdmin ? "" : " not") " Admin."
Gosub, RunAsAdmin
; more code
Return
RunAsAdmin: ; run as administrator
    If Not A_IsAdmin {
        Run, *RunAs %A_ScriptFullPath% ; Requires v1.0.92.01+
        ExitApp
    }
Return

Put the first block of code in the auto-execute section at the top of your script, and the second block somewhere near the bottom, after your hotkeys and other code.

Source

Spyre
  • 2,234
  • 1
  • 4
  • 24
  • thank you for your help, i ve tried it but it seems that it doesnt work... – Ram Apr 03 '21 at 21:14
  • Maybe look at other solutions here? https://stackoverflow.com/questions/43298908/how-to-add-administrator-privileges-to-autohotkey-script – Spyre Apr 03 '21 at 21:29