From a36e0a88f6f9378cba27c0438c25ef05cb2f000c Mon Sep 17 00:00:00 2001 From: Tom Najdek Date: Tue, 15 Oct 2024 16:22:18 +0200 Subject: [PATCH] Installer: Ignore failed installs if user has no admin rights (#4760) It's better to attempt to install into existing folder with some junk left over than to leave users in a reboot loop --- app/win/installer/installer.nsi | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/app/win/installer/installer.nsi b/app/win/installer/installer.nsi index 8669dba6b3..4b22de443c 100755 --- a/app/win/installer/installer.nsi +++ b/app/win/installer/installer.nsi @@ -618,19 +618,33 @@ Function AddQuickLaunchShortcut FunctionEnd Function CheckExistingInstall + UserInfo::GetAccountType + pop $0 ; $0 = "Admin" or "User" or "Guest". This is the account type. + ; If there is a pending file copy from a previous upgrade don't allow ; installing until after the system has rebooted. - IfFileExists "$INSTDIR\${FileMainEXE}.moz-upgrade" +1 +4 - MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WARN_RESTART_REQUIRED_UPGRADE)" IDNO +2 - Reboot - Quit + ${If} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-upgrade" + StrCmp $0 "Admin" +1 +4 + MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WARN_RESTART_REQUIRED_UPGRADE)" IDNO +2 + Reboot + Quit + ; Non-admins cannot depend on files being removed on restart. + ; Our only option is to remove these files and continue with the installation. + Delete "$INSTDIR\${FileMainEXE}.moz-upgrade" + Delete "$INSTDIR\${FileMainEXE}" + ${EndIf} ; If there is a pending file deletion from a previous uninstall don't allow ; installing until after the system has rebooted. - IfFileExists "$INSTDIR\${FileMainEXE}.moz-delete" +1 +4 - MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WARN_RESTART_REQUIRED_UNINSTALL)" IDNO +2 - Reboot - Quit + ${If} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-delete" + StrCmp $0 "Admin" +1 +4 + MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WARN_RESTART_REQUIRED_UNINSTALL)" IDNO +2 + Reboot + Quit + ; Non-admins cannot depend on files being removed on restart. + Delete "$INSTDIR\${FileMainEXE}.moz-delete" + Delete "$INSTDIR\${FileMainEXE}" + ${EndIf} ${If} ${FileExists} "$INSTDIR\${FileMainEXE}" ; Disable the next, cancel, and back buttons