Want more features on Pastebin? Sign Up, it's FREE!
Guest

RequireAdmin NSIS

By: Anders on Mar 15th, 2011  |  syntax: NullSoft Installer  |  size: 0.60 KB  |  views: 1,897  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Outfile RequireAdmin.exe
  2.  
  3. ; BEGIN 8< 8< 8< 8< 8< 8< 8< 8<
  4. ; BEGIN 8< 8< 8< 8< 8< 8< 8< 8<
  5. ; BEGIN 8< 8< 8< 8< 8< 8< 8< 8<
  6.  
  7. RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
  8.  
  9. !include LogicLib.nsh
  10.  
  11. Function .onInit
  12. UserInfo::GetAccountType
  13. pop $0
  14. ${If} $0 != "admin" ;Require admin rights on NT4+
  15.         MessageBox mb_iconstop "Administrator rights required!"
  16.         SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
  17.         Quit
  18. ${EndIf}
  19. FunctionEnd
  20.  
  21. ; END >8 >8 >8 >8 >8 >8 >8 >8
  22. ; END >8 >8 >8 >8 >8 >8 >8 >8
  23. ; END >8 >8 >8 >8 >8 >8 >8 >8
  24.  
  25. Page InstFiles
  26.  
  27. Section
  28. SectionEnd
clone this paste RAW Paste Data