-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nsis): boring per-machine only installer
- Loading branch information
Showing
9 changed files
with
98 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,89 @@ | ||
!include multiUserUi.nsh | ||
!include UAC.nsh | ||
|
||
!ifndef INSTALL_MODE_PER_ALL_USERS | ||
!include multiUserUi.nsh | ||
!endif | ||
|
||
!ifndef BUILD_UNINSTALLER | ||
Function StartApp | ||
!insertmacro UAC_AsUser_ExecShell "" "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "" "" "" | ||
FunctionEnd | ||
|
||
Function GuiInit | ||
!insertmacro UAC_PageElevation_OnGuiInit | ||
FunctionEnd | ||
|
||
!define MUI_FINISHPAGE_RUN | ||
!define MUI_FINISHPAGE_RUN_FUNCTION "StartApp" | ||
|
||
!define MUI_CUSTOMFUNCTION_GUIINIT GuiInit | ||
!ifndef INSTALL_MODE_PER_ALL_USERS | ||
!insertmacro PAGE_INSTALL_MODE | ||
Function GuiInit | ||
!insertmacro UAC_PageElevation_OnGuiInit | ||
FunctionEnd | ||
|
||
!insertmacro PAGE_INSTALL_MODE | ||
!define MUI_CUSTOMFUNCTION_GUIINIT GuiInit | ||
!endif | ||
!insertmacro MUI_PAGE_INSTFILES | ||
!insertmacro MUI_PAGE_FINISH | ||
!else | ||
!insertmacro PAGE_INSTALL_MODE | ||
!ifndef INSTALL_MODE_PER_ALL_USERS | ||
!insertmacro PAGE_INSTALL_MODE | ||
!endif | ||
!insertmacro MUI_UNPAGE_INSTFILES | ||
!endif | ||
|
||
!macro initMultiUser | ||
!insertmacro UAC_PageElevation_OnInit | ||
!ifdef INSTALL_MODE_PER_ALL_USERS | ||
!insertmacro setInstallModePerAllUsers | ||
!else | ||
!insertmacro UAC_PageElevation_OnInit | ||
|
||
${If} ${UAC_IsInnerInstance} | ||
${AndIfNot} ${UAC_IsAdmin} | ||
# special return value for outer instance so it knows we did not have admin rights | ||
SetErrorLevel 0x666666 | ||
Quit | ||
${EndIf} | ||
${If} ${UAC_IsInnerInstance} | ||
${AndIfNot} ${UAC_IsAdmin} | ||
# special return value for outer instance so it knows we did not have admin rights | ||
SetErrorLevel 0x666666 | ||
Quit | ||
${EndIf} | ||
|
||
!ifndef MULTIUSER_INIT_TEXT_ADMINREQUIRED | ||
!define MULTIUSER_INIT_TEXT_ADMINREQUIRED "$(^Caption) requires administrator privileges." | ||
!endif | ||
!ifndef MULTIUSER_INIT_TEXT_ADMINREQUIRED | ||
!define MULTIUSER_INIT_TEXT_ADMINREQUIRED "$(^Caption) requires administrator privileges." | ||
!endif | ||
|
||
!ifndef MULTIUSER_INIT_TEXT_POWERREQUIRED | ||
!define MULTIUSER_INIT_TEXT_POWERREQUIRED "$(^Caption) requires at least Power User privileges." | ||
!endif | ||
!ifndef MULTIUSER_INIT_TEXT_POWERREQUIRED | ||
!define MULTIUSER_INIT_TEXT_POWERREQUIRED "$(^Caption) requires at least Power User privileges." | ||
!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 computer." | ||
!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 computer." | ||
!endif | ||
|
||
# checks registry for previous installation path (both for upgrading, reinstall, or uninstall) | ||
StrCpy $hasPerMachineInstallation "0" | ||
StrCpy $hasPerUserInstallation "0" | ||
# checks registry for previous installation path (both for upgrading, reinstall, or uninstall) | ||
StrCpy $hasPerMachineInstallation "0" | ||
StrCpy $hasPerUserInstallation "0" | ||
|
||
# set installation mode to setting from a previous installation | ||
ReadRegStr $perMachineInstallationFolder HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation | ||
${if} $perMachineInstallationFolder != "" | ||
StrCpy $hasPerMachineInstallation "1" | ||
${endif} | ||
# set installation mode to setting from a previous installation | ||
ReadRegStr $perMachineInstallationFolder HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation | ||
${if} $perMachineInstallationFolder != "" | ||
StrCpy $hasPerMachineInstallation "1" | ||
${endif} | ||
|
||
ReadRegStr $perUserInstallationFolder HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation | ||
${if} $perUserInstallationFolder != "" | ||
StrCpy $hasPerUserInstallation "1" | ||
${endif} | ||
ReadRegStr $perUserInstallationFolder HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation | ||
${if} $perUserInstallationFolder != "" | ||
StrCpy $hasPerUserInstallation "1" | ||
${endif} | ||
|
||
${if} $hasPerUserInstallation == "1" | ||
${andif} $hasPerMachineInstallation == "0" | ||
!insertmacro setInstallModePerUser | ||
${elseif} $hasPerUserInstallation == "0" | ||
${andif} $hasPerMachineInstallation == "1" | ||
!insertmacro setInstallModePerAllUsers | ||
${else} | ||
# if there is no installation, or there is both per-user and per-machine | ||
!ifdef INSTALL_MODE_PER_ALL_USERS | ||
!insertmacro setInstallModePerAllUsers | ||
!else | ||
${if} $hasPerUserInstallation == "1" | ||
${andif} $hasPerMachineInstallation == "0" | ||
!insertmacro setInstallModePerUser | ||
!endif | ||
${endif} | ||
${elseif} $hasPerUserInstallation == "0" | ||
${andif} $hasPerMachineInstallation == "1" | ||
!insertmacro setInstallModePerAllUsers | ||
${else} | ||
# if there is no installation, or there is both per-user and per-machine | ||
!ifdef INSTALL_MODE_PER_ALL_USERS | ||
!insertmacro setInstallModePerAllUsers | ||
!else | ||
!insertmacro setInstallModePerUser | ||
!endif | ||
${endif} | ||
!endif | ||
!macroend | ||
|
||
!include "langs.nsh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters