I have my script run on several computers in the office but sometimes for some reason the program it open will give that UAC prompt somtimes it will just launch the program.
Is there a method to know if a program will prompt for elevation?
Way to detect if non AHK program will require elevation Topic is solved
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Way to detect if non AHK program will require elevation
I doubt if anybody could give you any set rules, other than the programmer has to decide on a "case by case basis". Usually you would try to see if the program can run with no admin privileges and if everything works well. However, there will be various applications that you seek to automate that require admin privileges or you can be in an environment that needs it (like an IT admin running a script to do upgrades), so it can't be helped.
Re: Way to detect if non AHK program will require elevation Topic is solved
Code: Select all
MsgBox % IsElevationRequired("C:\Windows\System32\rstrui.exe") == 1
IsElevationRequired(FilePath) {
Local
hModule := DllCall("GetModuleHandle", "Str", "shell32.dll", "Ptr")
IsElevationRequired := DllCall("GetProcAddress", "Ptr", hModule, "UInt", 865, "Ptr")
If (!hModule || !IsElevationRequired) {
Return -1
}
Return DllCall(IsElevationRequired, "WStr", FilePath)
}