PageRenderTime 202ms CodeModel.GetById 121ms app.highlight 1ms RepoModel.GetById 79ms app.codeStats 0ms

/admin/win/nsi/nsis_uac/UAC_AdminOnly.nsi

http://github.com/tomahawk-player/tomahawk
Unknown | 62 lines | 53 code | 9 blank | 0 comment | 0 complexity | 62665fed80223091ee931c276f8d3daa MD5 | raw file
 1RequestExecutionLevel user /* RequestExecutionLevel REQUIRED! */
 2!define APPNAME "UAC_AdminOnly"
 3Name "${APPNAME}"
 4OutFile "${APPNAME}.exe"
 5ShowInstDetails show
 6
 7!include UAC.nsh ;<<< New headerfile that does everything for you ;)
 8!include LogicLib.nsh
 9
10!define UACSTR.I.ElvAbortReqAdmin "This fancy app requires admin rights fool" ;custom error string, see _UAC.InitStrings macro in uac.nsh for more
11
12Function .OnInit
13${UAC.I.Elevate.AdminOnly}
14FunctionEnd
15
16Function .OnInstFailed
17${UAC.Unload}
18FunctionEnd
19Function .OnInstSuccess
20${UAC.Unload}
21FunctionEnd
22
23Function ExecCodeSegmentTest
24${If} "$1" != "666, the # of the beast"
25	MessageBox mb_ok "uh oh"
26	${EndIf}
27FunctionEnd
28
29Section "Info"
30!insertmacro _UAC.DbgDetailPrint
31
32StrCpy $1 "666, the # of the beast"
33!insertmacro UAC.CallFunctionAsUser ExecCodeSegmentTest
34SectionEnd
35
36page InstFiles
37
38/* LEGACY CODE: (now uses magic code from UAC.nsh)
39Function .OnInit
40UAC_Elevate:
41UAC::RunElevated 
42StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
43StrCmp 0 $0 0 UAC_Err ; Error?
44StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
45Quit
46UAC_Err:
47MessageBox mb_iconstop "Unable to elevate , error $0"
48Abort
49UAC_ElevationAborted:
50/*System::Call "user32::CreateWindowEx(i ${WS_EX_TRANSPARENT}|${WS_EX_LAYERED}, t 'Button', t 'blah', i 0, i 10, i 10, i 10, i 10, i 0, i 0, i 0) i .r0"
51ShowWindow $0 ${SW_SHOW}
52System::Call "user32::SetForegroundWindow(i r0) i."
53System::Call "user32::DestroyWindow(i r0) i."
54* /
55MessageBox mb_iconstop "This installer requires admin access, aborting!"
56Abort
57UAC_Success:
58StrCmp 1 $3 +4 ;Admin?
59StrCmp 3 $1 0 UAC_ElevationAborted ;Try again or abort?
60MessageBox mb_iconstop "This installer requires admin access, try again" ;Inform user...
61goto UAC_Elevate ;... and try again
62FunctionEnd*/