* added some comments
* added settings for registry key that enables the installation mode to be set to the mode from a previous installation * fixed a few typos git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5498 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
bce63d6a98
commit
48b9003ca1
2 changed files with 236 additions and 149 deletions
|
@ -13,6 +13,8 @@ Copyright
|
||||||
!verbose push
|
!verbose push
|
||||||
!verbose 3
|
!verbose 3
|
||||||
|
|
||||||
|
;Standard NSIS header files
|
||||||
|
|
||||||
!ifdef MULTIUSER_MUI
|
!ifdef MULTIUSER_MUI
|
||||||
!include MUI2.nsh
|
!include MUI2.nsh
|
||||||
!endif
|
!endif
|
||||||
|
@ -21,9 +23,13 @@ Copyright
|
||||||
!include WinVer.nsh
|
!include WinVer.nsh
|
||||||
!include FileFunc.nsh
|
!include FileFunc.nsh
|
||||||
|
|
||||||
|
;Variables
|
||||||
|
|
||||||
Var MultiUser.Privileges
|
Var MultiUser.Privileges
|
||||||
Var MultiUser.InstallMode
|
Var MultiUser.InstallMode
|
||||||
|
|
||||||
|
;Command line installation mode setting
|
||||||
|
|
||||||
!ifdef MULTIUSER_INSTALLMODE_COMMANDLINE
|
!ifdef MULTIUSER_INSTALLMODE_COMMANDLINE
|
||||||
!insertmacro GetParameters
|
!insertmacro GetParameters
|
||||||
!ifndef MULTIUSER_NOUNINSTALLER
|
!ifndef MULTIUSER_NOUNINSTALLER
|
||||||
|
@ -39,10 +45,18 @@ Var MultiUser.InstallMode
|
||||||
Var MultiUser.Result
|
Var MultiUser.Result
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
|
;Installation folder stored in registry
|
||||||
|
|
||||||
!ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
|
!ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
|
||||||
Var MultiUser.InstDir
|
Var MultiUser.InstDir
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
|
!ifdef MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY & MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME
|
||||||
|
Var MultiUser.DefaultKeyValue
|
||||||
|
!endif
|
||||||
|
|
||||||
|
;Windows Vista UAC setting
|
||||||
|
|
||||||
!if "${MULTIUSER_EXECUTIONLEVEL}" == Admin
|
!if "${MULTIUSER_EXECUTIONLEVEL}" == Admin
|
||||||
RequestExecutionLevel admin
|
RequestExecutionLevel admin
|
||||||
!define MULTIUSER_EXECUTIONLEVEL_ALLUSERS
|
!define MULTIUSER_EXECUTIONLEVEL_ALLUSERS
|
||||||
|
@ -64,6 +78,8 @@ Install modes
|
||||||
|
|
||||||
!macro MULTIUSER_INSTALLMODE_ALLUSERS UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
|
!macro MULTIUSER_INSTALLMODE_ALLUSERS UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
|
||||||
|
|
||||||
|
;Install mode initialization - per-machine
|
||||||
|
|
||||||
${ifnot} ${IsNT}
|
${ifnot} ${IsNT}
|
||||||
${orif} $MultiUser.Privileges == "Admin"
|
${orif} $MultiUser.Privileges == "Admin"
|
||||||
${orif} $MultiUser.Privileges == "Power"
|
${orif} $MultiUser.Privileges == "Power"
|
||||||
|
@ -78,7 +94,7 @@ Install modes
|
||||||
|
|
||||||
!ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
|
!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}"
|
ReadRegStr $MultiUser.InstDir HKLM "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME}"
|
||||||
|
|
||||||
${if} $MultiUser.InstDir != ""
|
${if} $MultiUser.InstDir != ""
|
||||||
StrCpy $INSTDIR $MultiUser.InstDir
|
StrCpy $INSTDIR $MultiUser.InstDir
|
||||||
|
@ -96,6 +112,8 @@ Install modes
|
||||||
|
|
||||||
!macro MULTIUSER_INSTALLMODE_CURRENTUSER UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
|
!macro MULTIUSER_INSTALLMODE_CURRENTUSER UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
|
||||||
|
|
||||||
|
;Install mode initialization - per-user
|
||||||
|
|
||||||
${if} ${IsNT}
|
${if} ${IsNT}
|
||||||
|
|
||||||
StrCpy $MultiUser.InstallMode CurrentUser
|
StrCpy $MultiUser.InstallMode CurrentUser
|
||||||
|
@ -112,7 +130,7 @@ Install modes
|
||||||
|
|
||||||
!ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
|
!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}"
|
ReadRegStr $MultiUser.InstDir HKCU "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME}"
|
||||||
|
|
||||||
${if} $MultiUser.InstDir != ""
|
${if} $MultiUser.InstDir != ""
|
||||||
StrCpy $INSTDIR $MultiUser.InstDir
|
StrCpy $INSTDIR $MultiUser.InstDir
|
||||||
|
@ -182,6 +200,8 @@ Installer/uninstaller initialization
|
||||||
|
|
||||||
!macro MULTIUSER_INIT_CHECKS UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
|
!macro MULTIUSER_INIT_CHECKS UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
|
||||||
|
|
||||||
|
;Installer initialization - check privileges and set install mode
|
||||||
|
|
||||||
!insertmacro MULTIUSER_INIT_TEXTS
|
!insertmacro MULTIUSER_INIT_TEXTS
|
||||||
|
|
||||||
UserInfo::GetAccountType
|
UserInfo::GetAccountType
|
||||||
|
@ -189,6 +209,8 @@ Installer/uninstaller initialization
|
||||||
|
|
||||||
${if} ${IsNT}
|
${if} ${IsNT}
|
||||||
|
|
||||||
|
;Check privileges
|
||||||
|
|
||||||
!if "${MULTIUSER_EXECUTIONLEVEL}" == Admin
|
!if "${MULTIUSER_EXECUTIONLEVEL}" == Admin
|
||||||
|
|
||||||
${if} $MultiUser.Privileges != "Admin"
|
${if} $MultiUser.Privileges != "Admin"
|
||||||
|
@ -212,6 +234,8 @@ Installer/uninstaller initialization
|
||||||
|
|
||||||
!ifdef MULTIUSER_EXECUTIONLEVEL_ALLUSERS
|
!ifdef MULTIUSER_EXECUTIONLEVEL_ALLUSERS
|
||||||
|
|
||||||
|
;Default to per-machine installation if possible
|
||||||
|
|
||||||
${if} $MultiUser.Privileges == "Admin"
|
${if} $MultiUser.Privileges == "Admin"
|
||||||
${orif} $MultiUser.Privileges == "Power"
|
${orif} $MultiUser.Privileges == "Power"
|
||||||
!ifndef MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
|
!ifndef MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
|
||||||
|
@ -219,6 +243,31 @@ Installer/uninstaller initialization
|
||||||
!else
|
!else
|
||||||
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
|
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
|
||||||
!endif
|
!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.AllUsers
|
||||||
|
${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.CurrentUser
|
||||||
|
${endif}
|
||||||
|
${endif}
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!endif
|
||||||
|
|
||||||
${else}
|
${else}
|
||||||
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
|
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
|
||||||
${endif}
|
${endif}
|
||||||
|
@ -231,6 +280,8 @@ Installer/uninstaller initialization
|
||||||
|
|
||||||
!ifdef MULTIUSER_INSTALLMODE_COMMANDLINE
|
!ifdef MULTIUSER_INSTALLMODE_COMMANDLINE
|
||||||
|
|
||||||
|
;Check for install mode setting on command line
|
||||||
|
|
||||||
${${UNINSTALLER_FUNCPREFIX}GetParameters} $MultiUser.Parameters
|
${${UNINSTALLER_FUNCPREFIX}GetParameters} $MultiUser.Parameters
|
||||||
|
|
||||||
${${UNINSTALLER_PREFIX}StrStr} $MultiUser.Result $MultiUser.Parameters "/CurrentUser"
|
${${UNINSTALLER_PREFIX}StrStr} $MultiUser.Result $MultiUser.Parameters "/CurrentUser"
|
||||||
|
@ -254,6 +305,8 @@ Installer/uninstaller initialization
|
||||||
|
|
||||||
${else}
|
${else}
|
||||||
|
|
||||||
|
;Not running Windows NT, per-user installation not supported
|
||||||
|
|
||||||
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
|
Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
|
||||||
|
|
||||||
${endif}
|
${endif}
|
||||||
|
@ -333,6 +386,8 @@ Modern UI 2 page
|
||||||
|
|
||||||
!macro MULTIUSER_PAGE_INSTALLMODE
|
!macro MULTIUSER_PAGE_INSTALLMODE
|
||||||
|
|
||||||
|
;Modern UI page for install mode
|
||||||
|
|
||||||
!verbose push
|
!verbose push
|
||||||
!verbose 3
|
!verbose 3
|
||||||
|
|
||||||
|
@ -349,6 +404,8 @@ Modern UI 2 page
|
||||||
|
|
||||||
!macro MULTIUSER_FUNCTION_INSTALLMODEPAGE PRE LEAVE
|
!macro MULTIUSER_FUNCTION_INSTALLMODEPAGE PRE LEAVE
|
||||||
|
|
||||||
|
;Page functions of Modern UI page
|
||||||
|
|
||||||
Function "${PRE}"
|
Function "${PRE}"
|
||||||
|
|
||||||
${ifnot} ${IsNT}
|
${ifnot} ${IsNT}
|
||||||
|
|
|
@ -145,7 +145,7 @@ FunctionEnd</pre>
|
||||||
have the required privileges. After the macros are inserted, the variable $MultiUser.Privileges
|
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>
|
will contain the current execution level (Admin, Power, User or Guest).</p>
|
||||||
<p>
|
<p>
|
||||||
The following additonal settings are available to customize the initialization:</p>
|
The following additional settings are available to customize the initialization:</p>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
@ -185,7 +185,8 @@ FunctionEnd</pre>
|
||||||
MULTIUSER_INIT_UNFUNCTIONQUIT
|
MULTIUSER_INIT_UNFUNCTIONQUIT
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
A custom fuction to be called when the installer is closed due to insufficient privileges.
|
A custom function to be called when the installer is closed due to insufficient
|
||||||
|
privileges.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -202,16 +203,45 @@ FunctionEnd</pre>
|
||||||
if Administrator or Power User rights are available (this is always the case if
|
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
|
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
|
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
|
for a single user. On Windows 95/98/Me installation for a single user is not possible.</p>
|
||||||
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>
|
<p>
|
||||||
After initialization, the variable $MultiUser.InstallMode will contain the current installation
|
The following settings are available to change the default installation mode:
|
||||||
mode (AllUsers or CurrentUser).
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<b>Setting</b>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<b>Description</b>
|
||||||
|
</td>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Set default to a per-user installation, even if the rights for a per-machine installation
|
||||||
|
are available.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Non-empty registry key that is created during the installation in either HKCU or
|
||||||
|
HKLM. The default installation mode will automatically be set to the previously
|
||||||
|
selected mode depending on the location of the key.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<p>
|
||||||
|
After initialization, the variable $MultiUser.InstallMode will contain the current
|
||||||
|
installation mode (AllUsers or CurrentUser).
|
||||||
</p>
|
</p>
|
||||||
<h3>
|
<h3>
|
||||||
<a name="step-show"></a>Mixed-Mode Installation</h3>
|
Mixed-Mode Installation</h3>
|
||||||
<p>
|
<p>
|
||||||
For the Admin and Power levels, both a per-machine as well as a per-user installation
|
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
|
is possible. If the Highest level is set and the user is an Administrator or Power
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue