Add privilege elevation

This commit is contained in:
Jorg Tretter
2020-09-01 11:39:25 -05:00
parent fba7ccb017
commit 6f595c3d0e

View File

@@ -1,6 +1,8 @@
SendMode Input SendMode Input
Menu, Tray, Icon, shell32.dll, 166 Menu, Tray, Icon, shell32.dll, 166
; 2020-02-06 - added privilege elevation
GoSub, RunAdmin
f9:: f9::
Gosub, ShowGui Gosub, ShowGui
@@ -148,5 +150,27 @@ ShowGui:
Gui, Add, Button, x5 y%yPos% w495 gButtonApply, Apply LanguageList and EntryOrder Gui, Add, Button, x5 y%yPos% w495 gButtonApply, Apply LanguageList and EntryOrder
yPos += 30 yPos += 30
Gui, Show, h%yPos% w505, [Hammerer] 2018-06-05 j.tretter@accenture.com Gui, Show, h%yPos% w505, [Hammerer] version 2020-02-06 joe.tretter@kcc.com
return return
; Run as admin
RunAdmin:
If !A_IsAdmin
{
if A_OSVersion not in WIN_2003,WIN_XP,WIN_2000
{
Run % "*RunAs " DllCall( "GetCommandLineW", "Str" ),, UseErrorLevel
if !ErrorLevel
ExitApp
}
MsgBox 0x31, Hammerer,
(LTrim Join`s
Hammere is running as a limited user. If you continue,
it will most likely not be able to interact with CAS Modeler.
`n
To continue anyway, click OK. Otherwise click Cancel.
)
IfMsgBox, Cancel
ExitApp
}
Return