PageRenderTime 16ms CodeModel.GetById 9ms RepoModel.GetById 1ms 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
Possible License(s): LGPL-2.1, BSD-3-Clause, GPL-3.0, GPL-2.0
  1. RequestExecutionLevel user /* RequestExecutionLevel REQUIRED! */
  2. !define APPNAME "UAC_AdminOnly"
  3. Name "${APPNAME}"
  4. OutFile "${APPNAME}.exe"
  5. ShowInstDetails show
  6. !include UAC.nsh ;<<< New headerfile that does everything for you ;)
  7. !include LogicLib.nsh
  8. !define UACSTR.I.ElvAbortReqAdmin "This fancy app requires admin rights fool" ;custom error string, see _UAC.InitStrings macro in uac.nsh for more
  9. Function .OnInit
  10. ${UAC.I.Elevate.AdminOnly}
  11. FunctionEnd
  12. Function .OnInstFailed
  13. ${UAC.Unload}
  14. FunctionEnd
  15. Function .OnInstSuccess
  16. ${UAC.Unload}
  17. FunctionEnd
  18. Function ExecCodeSegmentTest
  19. ${If} "$1" != "666, the # of the beast"
  20. MessageBox mb_ok "uh oh"
  21. ${EndIf}
  22. FunctionEnd
  23. Section "Info"
  24. !insertmacro _UAC.DbgDetailPrint
  25. StrCpy $1 "666, the # of the beast"
  26. !insertmacro UAC.CallFunctionAsUser ExecCodeSegmentTest
  27. SectionEnd
  28. page InstFiles
  29. /* LEGACY CODE: (now uses magic code from UAC.nsh)
  30. Function .OnInit
  31. UAC_Elevate:
  32. UAC::RunElevated
  33. StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
  34. StrCmp 0 $0 0 UAC_Err ; Error?
  35. StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
  36. Quit
  37. UAC_Err:
  38. MessageBox mb_iconstop "Unable to elevate , error $0"
  39. Abort
  40. UAC_ElevationAborted:
  41. /*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"
  42. ShowWindow $0 ${SW_SHOW}
  43. System::Call "user32::SetForegroundWindow(i r0) i."
  44. System::Call "user32::DestroyWindow(i r0) i."
  45. * /
  46. MessageBox mb_iconstop "This installer requires admin access, aborting!"
  47. Abort
  48. UAC_Success:
  49. StrCmp 1 $3 +4 ;Admin?
  50. StrCmp 3 $1 0 UAC_ElevationAborted ;Try again or abort?
  51. MessageBox mb_iconstop "This installer requires admin access, try again" ;Inform user...
  52. goto UAC_Elevate ;... and try again
  53. FunctionEnd*/