diff --git a/templates/nsis/boringInstaller.nsh b/templates/nsis/boringInstaller.nsh index e98e4a56afc..6045794de91 100644 --- a/templates/nsis/boringInstaller.nsh +++ b/templates/nsis/boringInstaller.nsh @@ -1,4 +1,5 @@ !include UAC.nsh +!include StdUtils.nsh !ifndef INSTALL_MODE_PER_ALL_USERS !include multiUserUi.nsh @@ -6,7 +7,7 @@ !ifndef BUILD_UNINSTALLER Function StartApp - !insertmacro UAC_AsUser_ExecShell "" "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "" "" "" + ${StdUtils.ExecShellAsUser} $0 "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "open" "" FunctionEnd !define MUI_FINISHPAGE_RUN @@ -41,10 +42,14 @@ !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 + ${If} ${UAC_IsAdmin} + !insertmacro setInstallModePerAllUsers + Goto functionEnd + ${else} + # special return value for outer instance so it knows we did not have admin rights + SetErrorLevel 0x666666 + Quit + ${EndIf} ${EndIf} !ifndef MULTIUSER_INIT_TEXT_ADMINREQUIRED @@ -78,13 +83,13 @@ ${GetOptions} $R0 "/allusers" $R1 ${IfNot} ${Errors} !insertmacro setInstallModePerAllUsers - Goto FEnd + Goto functionEnd ${EndIf} ${GetOptions} $R0 "/currentuser" $R1 ${IfNot} ${Errors} !insertmacro setInstallModePerUser - Goto FEnd + Goto functionEnd ${EndIf} ${if} $hasPerUserInstallation == "1" @@ -102,7 +107,7 @@ !endif ${endif} - FEnd: + functionEnd: !endif !macroend diff --git a/templates/nsis/installSection.nsh b/templates/nsis/installSection.nsh index ef980b206d7..6f5d6c54351 100644 --- a/templates/nsis/installSection.nsh +++ b/templates/nsis/installSection.nsh @@ -43,6 +43,33 @@ ${endif} !macroend +!macro registryAddInstallInfo + WriteRegStr SHCTX "${INSTALL_REGISTRY_KEY}" InstallLocation "$INSTDIR" + + ${if} $installMode == "all" + StrCpy $0 "/allusers" + StrCpy $1 "" + ${else} + StrCpy $0 "/currentuser" + StrCpy $1 " (only current user)" + ${endif} + + WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" DisplayName "${UNINSTALL_DISPLAY_NAME}$1" + # https://github.com/electron-userland/electron-builder/issues/750 + StrCpy $2 "$INSTDIR\${UNINSTALL_FILENAME}" + WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" UninstallString '"$2" $0' + + WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${VERSION}" + WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$appExe,0" + WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${COMPANY_NAME}" + WriteRegDWORD SHCTX "${UNINSTALL_REGISTRY_KEY}" NoModify 1 + WriteRegDWORD SHCTX "${UNINSTALL_REGISTRY_KEY}" NoRepair 1 + + ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 + IntFmt $0 "0x%08X" $0 + WriteRegDWORD SHCTX "${UNINSTALL_REGISTRY_KEY}" "EstimatedSize" "$0" +!macroend + InitPluginsDir !ifdef HEADER_ICO diff --git a/templates/nsis/installer.nsi b/templates/nsis/installer.nsi index 002565ebc57..da4de32995d 100644 --- a/templates/nsis/installer.nsi +++ b/templates/nsis/installer.nsi @@ -38,7 +38,6 @@ Function .onInit !insertmacro quitSuccess !else !insertmacro check64BitAndSetRegView - !insertmacro initMultiUser !ifdef ONE_CLICK !insertmacro ALLOW_ONLY_ONE_INSTALLER_INSTANCE @@ -48,6 +47,8 @@ Function .onInit ${EndIf} !endif + !insertmacro initMultiUser + !ifmacrodef customInit !insertmacro customInit !endif diff --git a/templates/nsis/multiUser.nsh b/templates/nsis/multiUser.nsh index 7b14bb92e32..f1f1c04a375 100644 --- a/templates/nsis/multiUser.nsh +++ b/templates/nsis/multiUser.nsh @@ -59,32 +59,4 @@ Var installMode ${endif} !endif !macroend -!endif - -# SHCTX is the hive HKLM if SetShellVarContext all, or HKCU if SetShellVarContext user -!macro registryAddInstallInfo - WriteRegStr SHCTX "${INSTALL_REGISTRY_KEY}" InstallLocation "$INSTDIR" - - ${if} $installMode == "all" - StrCpy $0 "/allusers" - StrCpy $1 "" - ${else} - StrCpy $0 "/currentuser" - StrCpy $1 " (only current user)" - ${endif} - - WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" DisplayName "${UNINSTALL_DISPLAY_NAME}$1" - # https://github.com/electron-userland/electron-builder/issues/750 - StrCpy $2 "$INSTDIR\${UNINSTALL_FILENAME}" - WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" UninstallString '"$2" $0' - - WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${VERSION}" - WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$appExe,0" - WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${COMPANY_NAME}" - WriteRegDWORD SHCTX "${UNINSTALL_REGISTRY_KEY}" NoModify 1 - WriteRegDWORD SHCTX "${UNINSTALL_REGISTRY_KEY}" NoRepair 1 - - ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 - IntFmt $0 "0x%08X" $0 - WriteRegDWORD SHCTX "${UNINSTALL_REGISTRY_KEY}" "EstimatedSize" "$0" -!macroend \ No newline at end of file +!endif \ No newline at end of file diff --git a/templates/nsis/multiUserUi.nsh b/templates/nsis/multiUserUi.nsh index 99e1f2e3c6f..4d5e4025d68 100755 --- a/templates/nsis/multiUserUi.nsh +++ b/templates/nsis/multiUserUi.nsh @@ -126,9 +126,8 @@ Var RadioButtonLabel1 SendMessage $MultiUser.InstallModePage.AllUsers ${BM_GETCHECK} 0 0 $MultiUser.InstallModePage.ReturnValue ${if} $MultiUser.InstallModePage.ReturnValue = ${BST_CHECKED} - ${if} ${UAC_IsAdmin} - !insertmacro setInstallModePerAllUsers - ${else} + !insertmacro setInstallModePerAllUsers + ${IfNot} ${UAC_IsAdmin} !ifdef MULTIUSER_INSTALLMODE_ALLOW_ELEVATION GetDlgItem $9 $HWNDParent 1 System::Call user32::GetFocus()i.s diff --git a/templates/nsis/oneClick.nsh b/templates/nsis/oneClick.nsh index 76c8b42de66..39578ede532 100644 --- a/templates/nsis/oneClick.nsh +++ b/templates/nsis/oneClick.nsh @@ -1,8 +1,8 @@ !ifdef RUN_AFTER_FINISH !ifndef BUILD_UNINSTALLER + !include StdUtils.nsh Function StartApp !ifdef INSTALL_MODE_PER_ALL_USERS - !include StdUtils.nsh ${StdUtils.ExecShellAsUser} $0 "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk" "open" "" !else ExecShell "" "$SMPROGRAMS\${PRODUCT_FILENAME}.lnk"