Permalink
Browse files

Warn if the installer is run as a non-admin.

  • Loading branch information...
1 parent a2dfc25 commit 3d6606119f038a9d0fedf18bcc10f9014e6076d0 @23Skidoo committed Oct 26, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 Nsisfile.nsi
View
@@ -52,13 +52,29 @@
InstType "Portable (just unpack the files)"
;--------------------------------
+;Macros
+
+!macro CheckAdmin thing
+UserInfo::GetAccountType
+pop $0
+${If} $0 != "admin" ;Require admin rights on NT4+
+ MessageBox MB_YESNO "It is recommended to run this ${thing} as administrator. Do you want to quit and restart the ${thing} manually with elevated privileges?" IDNO CheckAdminDone
+ SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
+ Quit
+${EndIf}
+CheckAdminDone:
+!macroend
+
+;--------------------------------
;Callbacks
Function .onInit
+ !insertmacro CheckAdmin "installer"
SetShellVarContext all
FunctionEnd
Function un.onInit
+ !insertmacro CheckAdmin "uninstaller"
SetShellVarContext all
FunctionEnd

0 comments on commit 3d66061

Please sign in to comment.