diff options
author | bitraid <bitraid@protonmail.ch> | 2018-10-30 14:06:10 +0200 |
---|---|---|
committer | bitraid <bitraid@protonmail.ch> | 2018-10-30 14:06:10 +0200 |
commit | c87e3b7f7337fb58c78f2dfe30c7bb0b6e4657b5 (patch) | |
tree | fed24754b184085780afb9e0d34faf6d4ce59ff0 /misc/nsis | |
parent | bf51ad8d78d8f4c21ef402677785238b398eef19 (diff) | |
download | qutebrowser-c87e3b7f7337fb58c78f2dfe30c7bb0b6e4657b5.tar.gz qutebrowser-c87e3b7f7337fb58c78f2dfe30c7bb0b6e4657b5.zip |
Always run the uninstaller as the correct user
When a standard user uses an admin account for elevation to change an
existing single-user installation to all-users, the uninstaller is now
run for the correct (standard) user (instead of the admin).
Diffstat (limited to 'misc/nsis')
-rwxr-xr-x | misc/nsis/install.nsh | 98 |
1 files changed, 52 insertions, 46 deletions
diff --git a/misc/nsis/install.nsh b/misc/nsis/install.nsh index 54681ee73..b38f38ed5 100755 --- a/misc/nsis/install.nsh +++ b/misc/nsis/install.nsh @@ -148,6 +148,48 @@ var KeepReg !macroend ; Functions +Function CheckInstallation + ; if there's an installed version, uninstall it first (I chose not to start the uninstaller silently, so that user sees what failed) + ; if both per-user and per-machine versions are installed, unistall the one that matches $MultiUser.InstallMode + StrCpy $0 "" + ${if} $HasCurrentModeInstallation = 1 + StrCpy $0 "$MultiUser.InstallMode" + ${else} + !if ${MULTIUSER_INSTALLMODE_ALLOW_BOTH_INSTALLATIONS} = 0 + ${if} $HasPerMachineInstallation = 1 + StrCpy $0 "AllUsers" ; if there's no per-user installation, but there's per-machine installation, uninstall it + ${elseif} $HasPerUserInstallation = 1 + StrCpy $0 "CurrentUser" ; if there's no per-machine installation, but there's per-user installation, uninstall it + ${endif} + !endif + ${endif} + + ${if} "$0" != "" + ${if} $0 == "AllUsers" + StrCpy $1 "$PerMachineUninstallString" + StrCpy $3 "$PerMachineInstallationFolder" + ${else} + StrCpy $1 "$PerUserUninstallString" + StrCpy $3 "$PerUserInstallationFolder" + ${endif} + ${if} ${silent} + StrCpy $2 "/S" + ${else} + StrCpy $2 "" + ${endif} + ${if} $KeepReg = 1 + StrCpy $4 "/upgrade" + ${endif} + ${endif} +FunctionEnd + +Function RunUninstaller + StrCpy $0 0 + ; $1 is quoted in registry; the _? param stops the uninstaller from copying + ; itself to the temporary directory, which is the only way for ExecWait to work + ExecWait '$1 /SS $2 _?=$3' $0 ; $1 is quoted in registry; the _? param stops the uninstaller from copying itself to the temporary directory, which is the only way for ExecWait to work +FunctionEnd + Function GetDefaultBrowser ReadRegStr $0 HKCU "SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice" "ProgId" ReadRegStr $1 HKCU "SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice" "ProgId" @@ -180,54 +222,17 @@ InstType "Minimal" Section "Core Files (required)" SectionCoreFiles SectionIn 1 2 3 RO - ; if there's an installed version, uninstall it first (I chose not to start - ; the uninstaller silently, so that user sees what failed) - ; if both per-user and per-machine versions are installed, unistall the one - ; that matches $MultiUser.InstallMode - StrCpy $0 "" - ${if} $HasCurrentModeInstallation = 1 - StrCpy $0 "$MultiUser.InstallMode" - ${else} - StrCpy $KeepReg 0 - !if ${MULTIUSER_INSTALLMODE_ALLOW_BOTH_INSTALLATIONS} = 0 - ${if} $HasPerMachineInstallation = 1 - ; if there's no per-user installation, but there's per-machine installation, uninstall it - StrCpy $0 "AllUsers" - ${elseif} $HasPerUserInstallation = 1 - ; if there's no per-machine installation, but there's per-user installation, uninstall it - StrCpy $0 "CurrentUser" - ${endif} - !endif - ${endif} - + !insertmacro UAC_AsUser_Call Function CheckInstallation ${UAC_SYNCREGISTERS} ${if} "$0" != "" - ${if} $0 == "AllUsers" - StrCpy $1 "$PerMachineUninstallString" - StrCpy $3 "$PerMachineInstallationFolder" - ${else} - StrCpy $1 "$PerUserUninstallString" - StrCpy $3 "$PerUserInstallationFolder" - ${endif} - ${if} ${silent} - StrCpy $2 "/S" - ${else} - StrCpy $2 "" - ${endif} - - ${if} $KeepReg = 1 - StrCpy $4 "/upgrade" - ${endif} - ; Make sure the uninstaller is there before attempting to run it ${if} ${FileExists} "$3\${UNINSTALL_FILENAME}" - HideWindow ClearErrors - StrCpy $0 0 - ; $1 is quoted in registry; the _? param stops the uninstaller from copying - ; itself to the temporary directory, which is the only way for ExecWait to work - ExecWait '$1 $4 /SS $2 _?=$3' $0 - + ${if} $0 == "AllUsers" + Call RunUninstaller + ${else} + !insertmacro UAC_AsUser_Call Function RunUninstaller ${UAC_SYNCREGISTERS} + ${endif} ${if} ${errors} ; stay in installer SetErrorLevel 2 ; Installation aborted by script BringToFront @@ -248,9 +253,10 @@ Section "Core Files (required)" SectionCoreFiles ${EndSwitch} ${endif} - ; the uninstaller doesn't delete itself when not copied to the temp directory - !insertmacro DeleteRetryAbort "$3\${UNINSTALL_FILENAME}" - RMDir "$3" + ${if} $IsAdmin = 1 + !insertmacro DeleteRetryAbort "$3\${UNINSTALL_FILENAME}" + RMDir "$3" + ${endif} ${endif} ${endif} |