NSIS: always remove the correct config/cache dirs

The uninstaller now removes the files of the user that started it, even
when it's using another account for elevation. The user has to run the
uninstaller directly though, because through Windows, it's starting
elevated from the get-go.
This commit is contained in:
bitraid 2018-10-19 14:11:49 +03:00
parent 97e7efba42
commit 538d417e69
No known key found for this signature in database
GPG Key ID: 140D99CA504654D3
1 changed files with 25 additions and 12 deletions

View File

@ -26,6 +26,18 @@ Var RunningFromInstaller ; installer started uninstaller using /uninstall parame
!insertmacro DeleteRetryAbortFunc "un."
!insertmacro CheckSingleInstanceFunc "un."
Function un.GetConfigDir
SetShellVarContext current
StrCpy $0 ${CONFIG_DIR}
SetShellVarContext all
FunctionEnd
Function un.GetCacheDir
SetShellVarContext current
StrCpy $0 ${CACHE_DIR}
SetShellVarContext all
FunctionEnd
Section "un.Program Files" SectionUninstallProgram
SectionIn RO
@ -75,24 +87,25 @@ SectionEnd
Section /o "!un.Program Settings" SectionRemoveSettings
; this section is executed only explicitly and shouldn't be placed in SectionUninstallProgram
SetShellVarContext current
RMDIR /r "${CONFIG_DIR}\data"
RMDIR /r "${CONFIG_DIR}\config"
RMDIR "${CONFIG_DIR}"
${if} $MultiUser.InstallMode == "AllUsers"
SetShellVarContext all
${if} $MultiUser.InstallMode == "CurrentUser"
!insertmacro UAC_AsUser_GetGlobal $0 ${CONFIG_DIR}
${else}
!insertmacro UAC_AsUser_Call Function un.GetConfigDir ${UAC_SYNCREGISTERS}
${endif}
RMDIR /r "$0\data"
RMDIR /r "$0\config"
RMDIR "$0"
SectionEnd
Section /o "un.Program Cache" SectionRemoveCache
; this section is executed only explicitly and shouldn't be placed in SectionUninstallProgram
SetShellVarContext current
RMDIR /r "${CACHE_DIR}\cache"
RMDIR "${CACHE_DIR}"
${if} $MultiUser.InstallMode == "AllUsers"
SetShellVarContext all
${if} $MultiUser.InstallMode == "CurrentUser"
!insertmacro UAC_AsUser_GetGlobal $0 ${CACHE_DIR}
${else}
!insertmacro UAC_AsUser_Call Function un.GetCacheDir ${UAC_SYNCREGISTERS}
${endif}
RMDIR /r "$0\cache"
RMDIR "$0"
SectionEnd
Section "-Uninstall" ; hidden section, must always be the last one!