diff --git a/bin/Packager/NullsoftInstaller.nsi b/bin/Packager/NullsoftInstaller.nsi --- a/bin/Packager/NullsoftInstaller.nsi +++ b/bin/Packager/NullsoftInstaller.nsi @@ -35,13 +35,26 @@ ;-------------------------------- XPStyle on -ShowInstDetails hide -ShowUninstDetails hide + Name "@{productname}" Caption "@{productname} @{version}" OutFile "@{setupname}" + +!define MULTIUSER_EXECUTIONLEVEL Highest +!define MULTIUSER_MUI +!define MULTIUSER_INSTALLMODE_COMMANDLINE +!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${regkey}" +!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "Install_Mode" +!define MULTIUSER_INSTALLMODE_INSTDIR "@{productname}" +!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${regkey}" +!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "Install_Dir" + +;!define MULTIUSER_USE_PROGRAMFILES64 +@{multiuser_use_programfiles64} +;!define MULTIUSER_USE_PROGRAMFILES64 +!include "MultiUser.nsh" !include "MUI2.nsh" !include "LogicLib.nsh" !include "x64.nsh" @@ -56,6 +69,7 @@ @{license} ;!insertmacro MUI_PAGE_LICENSE +!insertmacro MULTIUSER_PAGE_INSTALLMODE !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_UNPAGE_CONFIRM @@ -71,45 +85,37 @@ CRCCheck on SilentInstall normal -InstallDir "@{defaultinstdir}\@{productname}" -; InstallDirRegKey must use HKLM -InstallDirRegKey HKLM "${regkey}" "Install_Dir" - -Var /global ExistingInstallation - Function .onInit -!if @{architecture} == "x64" - ${IfNot} ${RunningX64} - MessageBox MB_OK|MB_ICONEXCLAMATION "This installer can only be run on 64-bit Windows." - Abort - ${EndIf} -!endif -;InstallDirRegKey must use HKLM -ReadRegStr $R0 HKLM "${regkey}" "Install_Dir" -${IfNot} $R0 == "" - StrCpy $ExistingInstallation $R0 -${EndIf} + !insertmacro MULTIUSER_INIT + !if @{architecture} == "x64" + ${IfNot} ${RunningX64} + MessageBox MB_OK|MB_ICONEXCLAMATION "This installer can only be run on 64-bit Windows." + Abort + ${EndIf} + !endif FunctionEnd +Function un.onInit + !insertmacro MULTIUSER_UNINIT +FunctionEnd ;-------------------------------- AutoCloseWindow false ; beginning (invisible) section Section -${IfNot} $ExistingInstallation == "" - ExecWait '"$ExistingInstallation\${uninstaller}" /S _?=$ExistingInstallation' -${EndIf} - WriteRegStr @{HKLM} "${regkey}" "Install_Dir" "$INSTDIR" + ExecWait '"$MultiUser.InstDir\${uninstaller}" /S _?=$MultiUser.InstDir' + WriteRegStr SHCTX "${regkey}" "Install_Dir" "$INSTDIR" + WriteRegStr SHCTX "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}" "$MultiUser.InstallMode" ; write uninstall strings - WriteRegStr @{HKLM} "${uninstkey}" "DisplayName" "@{productname}" - WriteRegStr @{HKLM} "${uninstkey}" "UninstallString" '"$INSTDIR\${uninstaller}"' - WriteRegStr @{HKLM} "${uninstkey}" "DisplayIcon" "$INSTDIR\@{iconname}" - WriteRegStr @{HKLM} "${uninstkey}" "URLInfoAbout" "@{website}" - WriteRegStr @{HKLM} "${uninstkey}" "Publisher" "@{company}" - WriteRegStr @{HKLM} "${uninstkey}" "DisplayVersion" "@{version}" + WriteRegStr SHCTX "${uninstkey}" "DisplayName" "@{productname}" + WriteRegStr SHCTX "${uninstkey}" "UninstallString" '"$INSTDIR\${uninstaller}"' + WriteRegStr SHCTX "${uninstkey}" "DisplayIcon" "$INSTDIR\@{iconname}" + WriteRegStr SHCTX "${uninstkey}" "URLInfoAbout" "@{website}" + WriteRegStr SHCTX "${uninstkey}" "Publisher" "@{company}" + WriteRegStr SHCTX "${uninstkey}" "DisplayVersion" "@{version}" @{registy_hook} @@ -152,8 +158,12 @@ ; TODO: we need something independent of a tier3.... nsExec::ExecToLog '"$INSTDIR\bin\kdeinit5.exe" "--shutdown"' -DeleteRegKey @{HKLM} "${uninstkey}" -DeleteRegKey @{HKLM} "${regkey}" +${If} $MultiUser.InstallMode == "CurrentUser" + SetShellVarContext current +${EndIf} + +DeleteRegKey SHCTX "${uninstkey}" +DeleteRegKey SHCTX "${regkey}" Delete "${startmenu}\@{productname}.lnk" Delete "${startmenu}\Uninstall.lnk" diff --git a/bin/Packager/NullsoftInstallerPackager.py b/bin/Packager/NullsoftInstallerPackager.py --- a/bin/Packager/NullsoftInstallerPackager.py +++ b/bin/Packager/NullsoftInstallerPackager.py @@ -70,6 +70,7 @@ defines.setdefault("architecture", CraftCore.compiler.architecture) defines.setdefault("company", "KDE") defines.setdefault("defaultinstdir", "$PROGRAMFILES64" if CraftCore.compiler.isX64() else "$PROGRAMFILES") + defines.setdefault("multiuser_use_programfiles64", "!define MULTIUSER_USE_PROGRAMFILES64" if CraftCore.compiler.isX64() else "") defines.setdefault("icon", os.path.join(CraftCore.standardDirs.craftBin(), "data", "icons", "craft.ico")) defines.setdefault("license", "") defines.setdefault("productname", self.subinfo.displayName) @@ -128,11 +129,6 @@ if not defines["license"] == "": defines["license"] = f"""!insertmacro MUI_PAGE_LICENSE "{defines["license"]}" """ - defines["HKLM"] = "HKLM32" if CraftCore.compiler.isX86() else "HKLM64" - defines["HKCR"] = "HKCR32" if CraftCore.compiler.isX86() else "HKCR64" - defines["HKCU"] = "HKCU32" if CraftCore.compiler.isX86() else "HKCU64" - - shortcuts = [] if "executable" in defines: shortcuts.append(self._createShortcut(defines["productname"], defines["executable"]))