forked from baasgeo/mapproxywindows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShellLinkRunAs.nsh
executable file
·54 lines (49 loc) · 1.5 KB
/
ShellLinkRunAs.nsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
!include LogicLib.nsh
!ifndef IPersistFile
!define IPersistFile {0000010b-0000-0000-c000-000000000046}
!endif
!ifndef CLSID_ShellLink
!define CLSID_ShellLink {00021401-0000-0000-C000-000000000046}
!define IID_IShellLinkA {000214EE-0000-0000-C000-000000000046}
!define IID_IShellLinkW {000214F9-0000-0000-C000-000000000046}
!define IShellLinkDataList {45e2b4ae-b1c3-11d0-b92f-00a0c90312e1}
!ifdef NSIS_UNICODE
!define IID_IShellLink ${IID_IShellLinkW}
!else
!define IID_IShellLink ${IID_IShellLinkA}
!endif
!endif
Function ShellLinkSetRunAs
!define ShellLinkSetRunAs `!insertmacro ShellLinkSetRunAsCall`
!macro ShellLinkSetRunAsCall _LINK _RESULT
Push `${_LINK}`
Call ShellLinkSetRunAs
Pop ${_RESULT}
!macroend
System::Store S
pop $9
System::Call "ole32::CoCreateInstance(g'${CLSID_ShellLink}',i0,i1,g'${IID_IShellLink}',*i.r1)i.r0"
${If} $0 = 0
System::Call "$1->0(g'${IPersistFile}',*i.r2)i.r0" ;QI
${If} $0 = 0
System::Call "$2->5(w '$9',i 0)i.r0" ;Load
${If} $0 = 0
System::Call "$1->0(g'${IShellLinkDataList}',*i.r3)i.r0" ;QI
${If} $0 = 0
System::Call "$3->6(*i.r4)i.r0" ;GetFlags
${If} $0 = 0
System::Call "$3->7(i $4|0x2000)i.r0" ;SetFlags ;SLDF_RUNAS_USER
${If} $0 = 0
System::Call "$2->6(w '$9',i1)i.r0" ;Save
${EndIf}
${EndIf}
System::Call "$3->2()" ;Release
${EndIf}
System::Call "$2->2()" ;Release
${EndIf}
${EndIf}
System::Call "$1->2()" ;Release
${EndIf}
push $0
System::Store L
FunctionEnd