Multi-User Header File: Installer configuration for multi-user Windows environments
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5471 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
730807022b
commit
0b8811f237
4 changed files with 802 additions and 0 deletions
|
@ -119,3 +119,11 @@
|
||||||
!ifdef MUI_UNABORTWARNING
|
!ifdef MUI_UNABORTWARNING
|
||||||
${LangFileString} MUI_UNTEXT_ABORTWARNING "Are you sure you want to quit $(^Name) Uninstall?"
|
${LangFileString} MUI_UNTEXT_ABORTWARNING "Are you sure you want to quit $(^Name) Uninstall?"
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
|
!ifdef MULTIUSER_INSTALLMODEPAGE
|
||||||
|
${LangFileString} MULTIUSER_TEXT_INSTALLMODE_TITLE "Choose Users"
|
||||||
|
${LangFileString} MULTIUSER_TEXT_INSTALLMODE_SUBTITLE "Choose for which users you want to install $(^NameDA)."
|
||||||
|
${LangFileString} MULTIUSER_INNERTEXT_INSTALLMODE_TOP "Select whether you want to install $(^NameDA) for yourself only or for all users of this computer. $(^ClickNext)"
|
||||||
|
${LangFileString} MULTIUSER_INNERTEXT_INSTALLMODE_ALLUSERS "Install for anyone using this computer"
|
||||||
|
${LangFileString} MULTIUSER_INNERTEXT_INSTALLMODE_CURRENTUSER "Install just for me"
|
||||||
|
!endif
|
||||||
|
|
406
Contrib/MultiUser/MultiUser.nsh
Normal file
406
Contrib/MultiUser/MultiUser.nsh
Normal file
|
@ -0,0 +1,406 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
MultiUser.nsh
|
||||||
|
|
||||||
|
Installer configuration for multi-user Windows environments
|
||||||
|
|
||||||
|
Copyright © 2008 Joost Verburg
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
!ifndef MULTIUSER_INCLUDED
|
||||||
|
!define MULTIUSER_INCLUDED
|
||||||
|
!verbose push
|
||||||
|
!verbose 3
|
||||||
|
|
||||||
|
!ifdef MULTIUSER_MUI
|
||||||
|
!include MUI2.nsh
|
||||||
|
!endif
|
||||||
|
!include nsDialogs.nsh
|
||||||
|
!include LogicLib.nsh
|
||||||
|
!include WinVer.nsh
|
||||||
|
!include FileFunc.nsh
|
||||||
|
|
||||||
|
Var MultiUser.Privileges
|
||||||
|
Var MultiUser.InstallMode
|
||||||
|
|
||||||
|
!ifdef MULTIUSER_INSTALLMODE_COMMANDLINE
|
||||||
|
!insertmacro GetParameters
|
||||||
|
!ifndef MULTIUSER_NOUNINSTALLER
|
||||||
|
!insertmacro un.GetParameters
|
||||||
|
!endif
|
||||||
|
!include StrFunc.nsh
|
||||||
|
${StrStr}
|
||||||
|
!ifndef MULTIUSER_NOUNINSTALLER
|
||||||
|
${UnStrStr}
|
||||||
|
!endif
|
||||||
|
|
||||||
|
Var MultiUser.Parameters
|
||||||
|
Var MultiUser.Result
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
|
||||||
|
Var MultiUser.InstDir
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!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
|
||||||
|
|
||||||
|
${ifnot} ${IsNT}
|
||||||
|
${orif} $MultiUser.Privileges == "Admin"
|
||||||
|
${orif} $MultiUser.Privileges == "Power"
|
||||||
|
|
||||||
|
StrCpy $MultiUser.InstallMode AllUsers
|
||||||
|
|
||||||
|
SetShellVarContext all
|
||||||
|
|
||||||
|
!ifdef MULTIUSER_INSTALLMODE_INSTDIR
|
||||||
|
StrCpy $INSTDIR "$PROGRAMFILES\${MULTIUSER_INSTALLMODE_INSTDIR}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
|
||||||
|
|
||||||
|
ReadRegStr $MultiUser.InstDir SHELL_CONTEXT "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME}"
|
||||||
|
|
||||||
|
${if} $MultiUser.InstDir != ""
|
||||||
|
StrCpy $INSTDIR $MultiUser.InstDir
|
||||||
|
${endif}
|
||||||
|
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!ifdef MULTIUSER_INSTALLMODE_FUNCTION
|
||||||
|
Call "${MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
${endif}
|
||||||
|
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
!macro MULTIUSER_INSTALLMODE_CURRENTUSER UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
|
||||||
|
|
||||||
|
${if} ${IsNT}
|
||||||
|
|
||||||
|
StrCpy $MultiUser.InstallMode CurrentUser
|
||||||
|
|
||||||
|
SetShellVarContext current
|
||||||
|
|
||||||
|
!ifdef MULTIUSER_INSTALLMODE_INSTDIR
|
||||||
|
${if} ${AtLeastWin2000}
|
||||||
|
StrCpy $INSTDIR "$LOCALAPPDATA\${MULTIUSER_INSTALLMODE_INSTDIR}"
|
||||||
|
${else}
|
||||||
|
StrCpy $INSTDIR "$PROGRAMFILES\${MULTIUSER_INSTALLMODE_INSTDIR}"
|
||||||
|
${endif}
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
|
||||||
|
|
||||||
|
ReadRegStr $MultiUser.InstDir SHELL_CONTEXT "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME}"
|
||||||
|
|
||||||
|
${if} $MultiUser.InstDir != ""
|
||||||
|
StrCpy $INSTDIR $MultiUser.InstDir
|
||||||
|
${endif}
|
||||||
|
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!ifdef MULTIUSER_INSTALLMODE_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
|
||||||
|
|
||||||
|
!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
|
||||||
|
|
||||||
|
!insertmacro MULTIUSER_INIT_TEXTS
|
||||||
|
|
||||||
|
UserInfo::GetAccountType
|
||||||
|
Pop $MultiUser.Privileges
|
||||||
|
|
||||||
|
${if} ${IsNT}
|
||||||
|
|
||||||
|
!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
|
||||||
|
|
||||||
|
${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
|
||||||
|
${else}
|
||||||
|
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
|
||||||
|
${endif}
|
||||||
|
|
||||||
|
!else
|
||||||
|
|
||||||
|
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
|
||||||
|
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!ifdef MULTIUSER_INSTALLMODE_COMMANDLINE
|
||||||
|
|
||||||
|
${${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}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
!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
|
||||||
|
|
||||||
|
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 /NOUNLOAD 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
|
374
Contrib/MultiUser/Readme.html
Normal file
374
Contrib/MultiUser/Readme.html
Normal file
|
@ -0,0 +1,374 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Multi-User Header File (MultiUser.nsh)</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
|
||||||
|
<style type="text/css">
|
||||||
|
td
|
||||||
|
{
|
||||||
|
padding: 5px;
|
||||||
|
vertical-align: top;
|
||||||
|
border-bottom: 1px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>
|
||||||
|
Multi-User Header File (MultiUser.nsh)</h1>
|
||||||
|
<p>
|
||||||
|
<i>Installer configuration for multi-user Windows environments</i></p>
|
||||||
|
<h2>
|
||||||
|
Table of Contents</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#introduction">Introduction</a></li>
|
||||||
|
<li><a href="#executionlevel">Initalization and Execution Level</a>
|
||||||
|
<li><a href="#installationmode">Installation Mode</a></ul>
|
||||||
|
<h2>
|
||||||
|
<a name="introduction"></a>Introduction</h2>
|
||||||
|
<p>
|
||||||
|
Modern Windows versions support multiple users accounts on a single computer, each
|
||||||
|
with different privileges. For security reasons, the privileges of applications
|
||||||
|
can also be limited. For an installer, the <i>execution level</i> and <i>installation
|
||||||
|
mode</i> are important. The execution level determines the privileges of the
|
||||||
|
installer application. For example, to install hardware drivers, administrator privileges
|
||||||
|
are required. Applications can also be installed for a single user or for all users
|
||||||
|
on a computer, which is determined by the installation mode. Installation for all
|
||||||
|
users requires a higher execution level as compared with a single user setup. The
|
||||||
|
MultiUser.nsh header files provides the features to automatically handle all these
|
||||||
|
aspects related to user accounts and installer privileges.</p>
|
||||||
|
<p>
|
||||||
|
Note that all settings need to be set before including the MultiUser.nsh header
|
||||||
|
file.</p>
|
||||||
|
<h2>
|
||||||
|
Initialization and <a name="executionlevel"></a>Execution Level </h2>
|
||||||
|
<p>
|
||||||
|
Before the MultiUser.nsh file is included, the MULTIUSER_EXECUTIONLEVEL define should
|
||||||
|
be set to one of the following values depending on the execution level that is required:</p>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<b>Value </b>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Description</b>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Typical application</b>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Admin
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Administrator privileges are required
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Installation of drivers, hardware management
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Power
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Power User privileges are required<br />
|
||||||
|
(Power Users no longer exist in Windows Vista. For Vista this is equivalent to Admin)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Installation for all users (writing to "Program Files" or HKLM registry
|
||||||
|
keys)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Highest
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Request the highest possible execution level for the current user
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Mixed-mode installer that can both be installed per-machine or per-user
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Standard
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
No special rights required
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Installation for current user only
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<p>
|
||||||
|
Insert the MULTIUSER_INIT and MULTIUSER_UNINT macros in the .onInit and un.onInit
|
||||||
|
function to verify these privileges. If no uninstaller is created in the script,
|
||||||
|
set MULTIUSER_NOUNINSTALL.</p>
|
||||||
|
<blockquote>
|
||||||
|
<pre>!define MULTIUSER_EXECUTIONLEVEL Highest
|
||||||
|
;!define MULTIUSER_NOUNINSTALL ;Uncomment if no uninstaller is created
|
||||||
|
!include MultiUser.nsh
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
Function .onInit
|
||||||
|
!insertmacro MULTIUSER_INIT
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function un.onInit
|
||||||
|
!insertmacro MULTIUSER_UNINIT
|
||||||
|
Function</pre>
|
||||||
|
</blockquote>
|
||||||
|
<p>
|
||||||
|
Whether the required privileges can be obtained depends on the user that starts
|
||||||
|
the installer:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Windows NT 4/2000/XP/2003 give the installer the same privileges as the user itself.
|
||||||
|
If the privileges of the user are not sufficient (e.g. Admin level is required is
|
||||||
|
set but the user has no administrator rights), the macros will display an error
|
||||||
|
message and quit the installer. If is however possible to manually run the installer
|
||||||
|
with an administrator account.</li>
|
||||||
|
<li>Windows Vista restricts the privileges of all applications by default. Depending
|
||||||
|
on requested execution level, MultiUser.nsh will set the RequestExecutionLevel flag
|
||||||
|
to request privileges. The user will be asked for confirmation and (if necessary)
|
||||||
|
for an administrator password.</li>
|
||||||
|
<li>Windows 95/98/98 do not set any restrictions on users or applications. Administrator
|
||||||
|
rights are always available.</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
It is recommended to insert these initialization macros before macros that require
|
||||||
|
user intervention. For example, it does not make sense to ask a user for an installer
|
||||||
|
language if the installer will quit afterwards because the user account does not
|
||||||
|
have the required privileges. After the macros are inserted, the variable $MultiUser.Privileges
|
||||||
|
will contain the current execution level (Admin, Power, User or Guest).</p>
|
||||||
|
<p>
|
||||||
|
The following additonal settings are available to customize the initialization:</p>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<b>Setting<td>
|
||||||
|
<b>Description</b>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MULTIUSER_INIT_TEXT_ADMINREQUIRED
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Error message to be displayed when administrator rights are required but not available.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MULTIUSER_INIT_TEXT_POWERREQUIRED
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Error message to be displayed when Power User rights are required but not available.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MULTIUSER_INIT_TEXT_ALLUSERSNOTPOSSIBLE
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Error message to be displayed when administrator or Power User rights are required
|
||||||
|
because of an installation mode setting on the command line (see below) but are
|
||||||
|
not available.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MULTIUSER_INIT_FUNCTIONQUIT<br />
|
||||||
|
MULTIUSER_INIT_UNFUNCTIONQUIT
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
A custom fuction to be called when the installer is closed due to insufficient privileges.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<h2>
|
||||||
|
<a name="installationmode"></a>Installation Mode</h2>
|
||||||
|
<p>
|
||||||
|
As mentioned before, applications can both be installed for a single users or for
|
||||||
|
all users on a computer. Applications for all users are typically installed in the
|
||||||
|
Program Files folder and appear in the Start Menu of every user. On the contrary,
|
||||||
|
applications for a single user are usually installed in the local Application Data
|
||||||
|
folder and only a appear in the Start Menu of the user who installed the application.</p>
|
||||||
|
<p>
|
||||||
|
By default, MultiUser.nsh will set the installation mode for a per-machine installation
|
||||||
|
if Administrator or Power User rights are available (this is always the case if
|
||||||
|
the execution level is set to Admin or Power, if Highest is set it depends on the
|
||||||
|
user account). For the Standard execution level the installation will always be
|
||||||
|
for a single user. If you prefer the default to be a per-user installation even
|
||||||
|
though the rights for a per-machine installation are available, define MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
|
||||||
|
before including User.nsh. On Windows 95/98/Me installation for a single user is
|
||||||
|
not possible.</p>
|
||||||
|
<p>
|
||||||
|
After initialization, the variable $MultiUser.InstallMode will contain the current installation
|
||||||
|
mode (AllUsers or CurrentUser).
|
||||||
|
</p>
|
||||||
|
<h3>
|
||||||
|
<a name="step-show"></a>Mixed-Mode Installation</h3>
|
||||||
|
<p>
|
||||||
|
For the Admin and Power levels, both a per-machine as well as a per-user installation
|
||||||
|
is possible. If the Highest level is set and the user is an Administrator or Power
|
||||||
|
User, both options are also available.</p>
|
||||||
|
<p>
|
||||||
|
Usually it's a good thing to give the user to choice between these options. For
|
||||||
|
users of the Modern UI version 2, a page is provided that asks the user for the
|
||||||
|
installation mode. To use this page, define MULTIUSER_MUI before including User.nsh.
|
||||||
|
Then, the MULTIUSER_PAGE_INSTALLMODE macro can be used just like a normal Modern
|
||||||
|
UI page (this page will automatically be skipped when running Windows 95/98/Me):</p>
|
||||||
|
<pre>!define MULTIUSER_EXECUTIONLEVEL Highes
|
||||||
|
<b>!define MULTIUSER_MUI</b>
|
||||||
|
!define MULTIUSER_INSTALLMODE_COMMANDLINE
|
||||||
|
!include MultiUser.nsh
|
||||||
|
!include MUI2.nsh
|
||||||
|
|
||||||
|
<b>!insertmacro MULTIUSER_PAGE_INSTALLMODE</b>
|
||||||
|
!insertmacro MUI_PAGE_DIRECTORY
|
||||||
|
!insertmacro MUI_PAGE_INSTFILES
|
||||||
|
|
||||||
|
!insertmacro MUI_LANGUAGE English
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
Function .onInit
|
||||||
|
!insertmacro MULTIUSER_INIT
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function un.onInit
|
||||||
|
!insertmacro MULTIUSER_UNINIT
|
||||||
|
FFunction
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
The MULTIUSER_INSTALLMODE_COMMANDLINE setting that also appears in this example
|
||||||
|
enables the installation mode to be set using the /AllUsers or /CurrentUser command
|
||||||
|
line parameters. This is especially useful for silent setup.</p>
|
||||||
|
<p>
|
||||||
|
The following settings can be used to customize the texts on the page (in addition
|
||||||
|
to the general Modern UI page settings):</p>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<b>Setting</b>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Description</b>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MULTIUSER_INSTALLMODEPAGE_TEXT_TOP
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Text to display on the top of the page.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MULTIUSER_INSTALLMODEPAGE_TEXT_ALLUSERS
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Text to display on the combo button for a per-machine installation.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MULTIUSER_INSTALLMODEPAGE_TEXT_CURRENTUSER
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Text to display on the combo button for a per-user installation.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<h3>
|
||||||
|
Installation Mode Initalization</h3>
|
||||||
|
<p>
|
||||||
|
The SetShellVarContext flag (which determines the folders for e.g. shortcuts, like
|
||||||
|
$DESKTOP) is automatically set depending on the installation mode. In addition,
|
||||||
|
the following settings can be used to perform additional actions when the installation
|
||||||
|
mode is initialized:</p>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<b>Setting</b>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Description</b>
|
||||||
|
</td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MULTIUSER_INSTALLMODE_INSTDIR
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Name of the folder in which to install the application, without a path. This folder
|
||||||
|
will be located in Program Files for a per-machine installation and in the local
|
||||||
|
Application Data folder for a per-user installation (if supported).
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Registry key from which to obtain a previously stored installation folder. It will
|
||||||
|
be retrieved from HKCU for per-user and HKLM for per-machine.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MULTIUSER_INSTALLMODE_FUNCTION<br />
|
||||||
|
MULTIUSER_INSTALLMODE_UNFUNCTION
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
A custom fuction to be called during the initialization of the installation mode
|
||||||
|
to set additional installer settings that depend on the mode
|
||||||
|
</td>
|
||||||
|
</table>
|
||||||
|
<p>
|
||||||
|
To set the installation mode manually, call one of these four functions:</p>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<b>Function name</b>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Installation mode</b>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MultiUser.InstallMode.AllUsers
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Installer: Per-machine installation
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MultiUser.InstallMode.CurrentUser
|
||||||
|
<td>
|
||||||
|
Installer: Per-user installation
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
un.MultiUser.InstallMode.AllUsers<td>
|
||||||
|
Uninstaller: Per-machine installation
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
un.MultiUser.InstallMode.CurrentUser<td>
|
||||||
|
Uninstaller: Per-user installation
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
14
Contrib/MultiUser/SConscript
Normal file
14
Contrib/MultiUser/SConscript
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
target = 'MultiUser'
|
||||||
|
|
||||||
|
docs = Split("""
|
||||||
|
Readme.html
|
||||||
|
""")
|
||||||
|
|
||||||
|
includes = Split("""
|
||||||
|
MultiUser.nsh
|
||||||
|
""")
|
||||||
|
|
||||||
|
Import('defenv')
|
||||||
|
|
||||||
|
defenv.DistribeDocs(docs, path=target)
|
||||||
|
defenv.DistributeInclude(includes)
|
Loading…
Add table
Add a link
Reference in a new issue