/usr/share/nsis/Include/MultiUser.nsh is in nsis-common 2.50-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 | /*
MultiUser.nsh
Installer configuration for multi-user Windows environments
Copyright 2008-2015 Joost Verburg
*/
!ifndef MULTIUSER_INCLUDED
!define MULTIUSER_INCLUDED
!verbose push
!verbose 3
;Standard NSIS header files
!ifdef MULTIUSER_MUI
!include MUI2.nsh
!endif
!include nsDialogs.nsh
!include LogicLib.nsh
!include WinVer.nsh
!include FileFunc.nsh
;Variables
Var MultiUser.Privileges
Var MultiUser.InstallMode
;Command line installation mode setting
!ifdef MULTIUSER_INSTALLMODE_COMMANDLINE
!include StrFunc.nsh
!ifndef StrStr_INCLUDED
${StrStr}
!endif
!ifndef MULTIUSER_NOUNINSTALL
!ifndef UnStrStr_INCLUDED
${UnStrStr}
!endif
!endif
Var MultiUser.Parameters
Var MultiUser.Result
!endif
;Installation folder stored in registry
!ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
Var MultiUser.InstDir
!endif
!ifdef MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY & MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME
Var MultiUser.DefaultKeyValue
!endif
;Windows Vista UAC setting
!if "${MULTIUSER_EXECUTIONLEVEL}" == Admin
RequestExecutionLevel admin
!define MULTIUSER_EXECUTIONLEVEL_ALLUSERS
!else if "${MULTIUSER_EXECUTIONLEVEL}" == Power
RequestExecutionLevel admin
!define MULTIUSER_EXECUTIONLEVEL_ALLUSERS
!else if "${MULTIUSER_EXECUTIONLEVEL}" == Highest
RequestExecutionLevel highest
!define MULTIUSER_EXECUTIONLEVEL_ALLUSERS
!else
RequestExecutionLevel user
!endif
/*
Install modes
*/
!macro MULTIUSER_INSTALLMODE_ALLUSERS UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
;Install mode initialization - per-machine
${ifnot} ${IsNT}
${orif} $MultiUser.Privileges == "Admin"
${orif} $MultiUser.Privileges == "Power"
StrCpy $MultiUser.InstallMode AllUsers
SetShellVarContext all
!if "${UNINSTALLER_PREFIX}" != UN
;Set default installation location for installer
!ifdef MULTIUSER_INSTALLMODE_INSTDIR
StrCpy $INSTDIR "$PROGRAMFILES\${MULTIUSER_INSTALLMODE_INSTDIR}"
!endif
!endif
!ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
ReadRegStr $MultiUser.InstDir HKLM "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME}"
${if} $MultiUser.InstDir != ""
StrCpy $INSTDIR $MultiUser.InstDir
${endif}
!endif
!ifdef MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION
Call "${MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION}"
!endif
${endif}
!macroend
!macro MULTIUSER_INSTALLMODE_CURRENTUSER UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
;Install mode initialization - per-user
${if} ${IsNT}
StrCpy $MultiUser.InstallMode CurrentUser
SetShellVarContext current
!if "${UNINSTALLER_PREFIX}" != UN
;Set default installation location for installer
!ifdef MULTIUSER_INSTALLMODE_INSTDIR
${if} ${AtLeastWin2000}
StrCpy $INSTDIR "$LOCALAPPDATA\${MULTIUSER_INSTALLMODE_INSTDIR}"
${else}
StrCpy $INSTDIR "$PROGRAMFILES\${MULTIUSER_INSTALLMODE_INSTDIR}"
${endif}
!endif
!endif
!ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
ReadRegStr $MultiUser.InstDir HKCU "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME}"
${if} $MultiUser.InstDir != ""
StrCpy $INSTDIR $MultiUser.InstDir
${endif}
!endif
!ifdef MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION
Call "${MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION}"
!endif
${endif}
!macroend
Function MultiUser.InstallMode.AllUsers
!insertmacro MULTIUSER_INSTALLMODE_ALLUSERS "" ""
FunctionEnd
Function MultiUser.InstallMode.CurrentUser
!insertmacro MULTIUSER_INSTALLMODE_CURRENTUSER "" ""
FunctionEnd
!ifndef MULTIUSER_NOUNINSTALL
Function un.MultiUser.InstallMode.AllUsers
!insertmacro MULTIUSER_INSTALLMODE_ALLUSERS UN .un
FunctionEnd
Function un.MultiUser.InstallMode.CurrentUser
!insertmacro MULTIUSER_INSTALLMODE_CURRENTUSER UN .un
FunctionEnd
!endif
/*
Installer/uninstaller initialization
*/
!macro MULTIUSER_INIT_QUIT UNINSTALLER_FUNCPREFIX
!ifdef MULTIUSER_INIT_${UNINSTALLER_FUNCPREFIX}FUNCTIONQUIT
Call "${MULTIUSER_INIT_${UNINSTALLER_FUNCPREFIX}FUCTIONQUIT}
!else
Quit
!endif
!macroend
!macro MULTIUSER_INIT_TEXTS
!ifndef MULTIUSER_INIT_TEXT_ADMINREQUIRED
!define MULTIUSER_INIT_TEXT_ADMINREQUIRED "$(^Caption) requires administrator priviledges."
!endif
!ifndef MULTIUSER_INIT_TEXT_POWERREQUIRED
!define MULTIUSER_INIT_TEXT_POWERREQUIRED "$(^Caption) requires at least Power User priviledges."
!endif
!ifndef MULTIUSER_INIT_TEXT_ALLUSERSNOTPOSSIBLE
!define MULTIUSER_INIT_TEXT_ALLUSERSNOTPOSSIBLE "Your user account does not have sufficient privileges to install $(^Name) for all users of this compuetr."
!endif
!macroend
!macro MULTIUSER_INIT_CHECKS UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
;Installer initialization - check privileges and set install mode
!insertmacro MULTIUSER_INIT_TEXTS
UserInfo::GetAccountType
Pop $MultiUser.Privileges
${if} ${IsNT}
;Check privileges
!if "${MULTIUSER_EXECUTIONLEVEL}" == Admin
${if} $MultiUser.Privileges != "Admin"
MessageBox MB_OK|MB_ICONSTOP "${MULTIUSER_INIT_TEXT_ADMINREQUIRED}"
!insertmacro MULTIUSER_INIT_QUIT "${UNINSTALLER_FUNCPREFIX}"
${endif}
!else if "${MULTIUSER_EXECUTIONLEVEL}" == Power
${if} $MultiUser.Privileges != "Power"
${andif} $MultiUser.Privileges != "Admin"
${if} ${AtMostWinXP}
MessageBox MB_OK|MB_ICONSTOP "${MULTIUSER_INIT_TEXT_POWERREQUIRED}"
${else}
MessageBox MB_OK|MB_ICONSTOP "${MULTIUSER_INIT_TEXT_ADMINREQUIRED}"
${endif}
!insertmacro MULTIUSER_INIT_QUIT "${UNINSTALLER_FUNCPREFIX}"
${endif}
!endif
!ifdef MULTIUSER_EXECUTIONLEVEL_ALLUSERS
;Default to per-machine installation if possible
${if} $MultiUser.Privileges == "Admin"
${orif} $MultiUser.Privileges == "Power"
!ifndef MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
!else
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
!endif
!ifdef MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY & MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME
;Set installation mode to setting from a previous installation
!ifndef MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
ReadRegStr $MultiUser.DefaultKeyValue HKLM "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}"
${if} $MultiUser.DefaultKeyValue == ""
ReadRegStr $MultiUser.DefaultKeyValue HKCU "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}"
${if} $MultiUser.DefaultKeyValue != ""
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
${endif}
${endif}
!else
ReadRegStr $MultiUser.DefaultKeyValue HKCU "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}"
${if} $MultiUser.DefaultKeyValue == ""
ReadRegStr $MultiUser.DefaultKeyValue HKLM "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}"
${if} $MultiUser.DefaultKeyValue != ""
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
${endif}
${endif}
!endif
!endif
${else}
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
${endif}
!else
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
!endif
!ifdef MULTIUSER_INSTALLMODE_COMMANDLINE
;Check for install mode setting on command line
${${UNINSTALLER_FUNCPREFIX}GetParameters} $MultiUser.Parameters
${${UNINSTALLER_PREFIX}StrStr} $MultiUser.Result $MultiUser.Parameters "/CurrentUser"
${if} $MultiUser.Result != ""
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
${endif}
${${UNINSTALLER_PREFIX}StrStr} $MultiUser.Result $MultiUser.Parameters "/AllUsers"
${if} $MultiUser.Result != ""
${if} $MultiUser.Privileges == "Admin"
${orif} $MultiUser.Privileges == "Power"
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
${else}
MessageBox MB_OK|MB_ICONSTOP "${MULTIUSER_INIT_TEXT_ALLUSERSNOTPOSSIBLE}"
${endif}
${endif}
!endif
${else}
;Not running Windows NT, per-user installation not supported
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
${endif}
!macroend
!macro MULTIUSER_INIT
!verbose push
!verbose 3
!insertmacro MULTIUSER_INIT_CHECKS "" ""
!verbose pop
!macroend
!ifndef MULTIUSER_NOUNINSTALL
!macro MULTIUSER_UNINIT
!verbose push
!verbose 3
!insertmacro MULTIUSER_INIT_CHECKS Un un.
!verbose pop
!macroend
!endif
/*
Modern UI 2 page
*/
!ifdef MULTIUSER_MUI
!macro MULTIUSER_INSTALLMODEPAGE_INTERFACE
!ifndef MULTIUSER_INSTALLMODEPAGE_INTERFACE
!define MULTIUSER_INSTALLMODEPAGE_INTERFACE
Var MultiUser.InstallModePage
Var MultiUser.InstallModePage.Text
Var MultiUser.InstallModePage.AllUsers
Var MultiUser.InstallModePage.CurrentUser
Var MultiUser.InstallModePage.ReturnValue
!endif
!macroend
!macro MULTIUSER_PAGEDECLARATION_INSTALLMODE
!insertmacro MUI_SET MULTIUSER_${MUI_PAGE_UNINSTALLER_PREFIX}INSTALLMODEPAGE ""
!insertmacro MULTIUSER_INSTALLMODEPAGE_INTERFACE
!insertmacro MUI_DEFAULT MULTIUSER_INSTALLMODEPAGE_TEXT_TOP "$(MULTIUSER_INNERTEXT_INSTALLMODE_TOP)"
!insertmacro MUI_DEFAULT MULTIUSER_INSTALLMODEPAGE_TEXT_ALLUSERS "$(MULTIUSER_INNERTEXT_INSTALLMODE_ALLUSERS)"
!insertmacro MUI_DEFAULT MULTIUSER_INSTALLMODEPAGE_TEXT_CURRENTUSER "$(MULTIUSER_INNERTEXT_INSTALLMODE_CURRENTUSER)"
PageEx custom
PageCallbacks MultiUser.InstallModePre_${MUI_UNIQUEID} MultiUser.InstallModeLeave_${MUI_UNIQUEID}
Caption " "
PageExEnd
!insertmacro MULTIUSER_FUNCTION_INSTALLMODEPAGE MultiUser.InstallModePre_${MUI_UNIQUEID} MultiUser.InstallModeLeave_${MUI_UNIQUEID}
!undef MULTIUSER_INSTALLMODEPAGE_TEXT_TOP
!undef MULTIUSER_INSTALLMODEPAGE_TEXT_ALLUSERS
!undef MULTIUSER_INSTALLMODEPAGE_TEXT_CURRENTUSER
!macroend
!macro MULTIUSER_PAGE_INSTALLMODE
;Modern UI page for install mode
!verbose push
!verbose 3
!ifndef MULTIUSER_EXECUTIONLEVEL_ALLUSERS
!error "A mixed-mode installation requires MULTIUSER_EXECUTIONLEVEL to be set to Admin, Power or Highest."
!endif
!insertmacro MUI_PAGE_INIT
!insertmacro MULTIUSER_PAGEDECLARATION_INSTALLMODE
!verbose pop
!macroend
!macro MULTIUSER_FUNCTION_INSTALLMODEPAGE PRE LEAVE
;Page functions of Modern UI page
Function "${PRE}"
${ifnot} ${IsNT}
Abort
${endif}
${if} $MultiUser.Privileges != "Power"
${andif} $MultiUser.Privileges != "Admin"
Abort
${endif}
!insertmacro MUI_PAGE_FUNCTION_CUSTOM PRE
!insertmacro MUI_HEADER_TEXT_PAGE $(MULTIUSER_TEXT_INSTALLMODE_TITLE) $(MULTIUSER_TEXT_INSTALLMODE_SUBTITLE)
nsDialogs::Create 1018
Pop $MultiUser.InstallModePage
${NSD_CreateLabel} 0u 0u 300u 20u "${MULTIUSER_INSTALLMODEPAGE_TEXT_TOP}"
Pop $MultiUser.InstallModePage.Text
${NSD_CreateRadioButton} 20u 50u 280u 10u "${MULTIUSER_INSTALLMODEPAGE_TEXT_ALLUSERS}"
Pop $MultiUser.InstallModePage.AllUsers
${NSD_CreateRadioButton} 20u 70u 280u 10u "${MULTIUSER_INSTALLMODEPAGE_TEXT_CURRENTUSER}"
Pop $MultiUser.InstallModePage.CurrentUser
${if} $MultiUser.InstallMode == "AllUsers"
SendMessage $MultiUser.InstallModePage.AllUsers ${BM_SETCHECK} ${BST_CHECKED} 0
${else}
SendMessage $MultiUser.InstallModePage.CurrentUser ${BM_SETCHECK} ${BST_CHECKED} 0
${endif}
!insertmacro MUI_PAGE_FUNCTION_CUSTOM SHOW
nsDialogs::Show
FunctionEnd
Function "${LEAVE}"
SendMessage $MultiUser.InstallModePage.AllUsers ${BM_GETCHECK} 0 0 $MultiUser.InstallModePage.ReturnValue
${if} $MultiUser.InstallModePage.ReturnValue = ${BST_CHECKED}
Call MultiUser.InstallMode.AllUsers
${else}
Call MultiUser.InstallMode.CurrentUser
${endif}
!insertmacro MUI_PAGE_FUNCTION_CUSTOM LEAVE
FunctionEnd
!macroend
!endif
!verbose pop
!endif
|