diff --git a/browser/installer/windows/nsis/installer.nsi b/browser/installer/windows/nsis/installer.nsi index f25467eecaf..3dba7834a30 100755 --- a/browser/installer/windows/nsis/installer.nsi +++ b/browser/installer/windows/nsis/installer.nsi @@ -107,6 +107,7 @@ VIAddVersionKey "FileDescription" "${BrandShortName} Installer" !insertmacro CreateRegKey !insertmacro CanWriteToInstallDir !insertmacro CheckDiskSpace +!insertmacro CleanVirtualStore !insertmacro AddHandlerValues !insertmacro GetSingleInstallPath @@ -253,6 +254,10 @@ Section "-Application" Section1 StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} (${AppVersion})" DeleteRegKey HKLM "$0" + ; Remove files that may be left behind by the application in the + ; VirtualStore directory. + ${CleanVirtualStore} + ${If} $InstallType != 1 ; Custom installs. ; If DOMi is installed and this install includes DOMi remove it from diff --git a/browser/installer/windows/nsis/shared.nsh b/browser/installer/windows/nsis/shared.nsh index 862cee9d079..304c2d29c7b 100755 --- a/browser/installer/windows/nsis/shared.nsh +++ b/browser/installer/windows/nsis/shared.nsh @@ -54,6 +54,10 @@ ${SetUninstallKeys} ${FixClassKeys} + + ; Remove files that may be left behind by the application in the + ; VirtualStore directory. + ${CleanVirtualStore} !macroend !define PostUpdate "!insertmacro PostUpdate" diff --git a/browser/installer/windows/nsis/uninstaller.nsi b/browser/installer/windows/nsis/uninstaller.nsi index 7facaa58c31..cd415e30ba1 100755 --- a/browser/installer/windows/nsis/uninstaller.nsi +++ b/browser/installer/windows/nsis/uninstaller.nsi @@ -83,12 +83,14 @@ Var TmpVal VIAddVersionKey "FileDescription" "${BrandShortName} Helper" !insertmacro AddHandlerValues +!insertmacro CleanVirtualStore !insertmacro RegCleanMain !insertmacro RegCleanUninstall !insertmacro WriteRegStr2 !insertmacro WriteRegDWORD2 !insertmacro un.RegCleanMain !insertmacro un.RegCleanUninstall +!insertmacro un.CleanVirtualStore !insertmacro un.CloseApp !insertmacro un.GetSecondInstallPath @@ -252,6 +254,10 @@ Section "Uninstall" ${RemoveDir} "$INSTDIR" ${EndIf} + ; Remove files that may be left behind by the application in the + ; VirtualStore directory. + ${un.CleanVirtualStore} + ; Refresh desktop icons otherwise the start menu internet item won't be ; removed and other ugly things will happen like recreation of the registry ; key by the OS under some conditions. diff --git a/toolkit/mozapps/installer/windows/nsis/common.nsh b/toolkit/mozapps/installer/windows/nsis/common.nsh index e1b193afa2d..8b0795302f6 100755 --- a/toolkit/mozapps/installer/windows/nsis/common.nsh +++ b/toolkit/mozapps/installer/windows/nsis/common.nsh @@ -1990,3 +1990,86 @@ Exch $R9 ; exchange the new $R9 value with the top of the stack !endif !macroend +/** + * If present removes the VirtualStore directory for this installation. Uses the + * program files directory path and the current install location to determine + * the sub-directory in the VirtualStore directory. +*/ +!macro CleanVirtualStore + !ifndef ${_MOZFUNC_UN}CleanVirtualStore + !verbose push + !verbose ${_MOZFUNC_VERBOSE} + !define ${_MOZFUNC_UN}CleanVirtualStore "!insertmacro ${_MOZFUNC_UN}CleanVirtualStoreCall" + + Function ${_MOZFUNC_UN}CleanVirtualStore + Push $R9 + Push $R8 + Push $R7 + + StrLen $R9 "$INSTDIR" + + ; Get the installation's directory name including the preceding slash + start: + IntOp $R8 $R8 - 1 + IntCmp $R8 -$R9 end end 0 + StrCpy $R7 "$INSTDIR" 1 $R8 + StrCmp $R7 "\" 0 start + + StrCpy $R9 "$INSTDIR" "" $R8 + + ClearErrors + GetFullPathName $R8 "$PROGRAMFILES$R9" + IfErrors end + GetFullPathName $R7 "$INSTDIR" + + ; Compare the installation's directory path with the path created by + ; concatenating the installation's directory name and the path to the + ; program files directory. + StrCmp "$R7" "$R8" 0 end + + StrCpy $R8 "$PROGRAMFILES" "" 2 ; Remove the drive letter and colon + StrCpy $R7 "$PROFILE\AppData\Local\VirtualStore$R8$R9" + + IfFileExists "$R7" 0 end + RmDir /r "$R7" + + end: + ClearErrors + + Pop $R7 + Pop $R8 + Pop $R9 + FunctionEnd + + !verbose pop + !endif +!macroend + +!macro CleanVirtualStoreCall + !verbose push + !verbose ${_MOZFUNC_VERBOSE} + Call CleanVirtualStore + !verbose pop +!macroend + +!macro un.CleanVirtualStoreCall + !verbose push + !verbose ${_MOZFUNC_VERBOSE} + Call un.CleanVirtualStore + !verbose pop +!macroend + +!macro un.CleanVirtualStore + !ifndef un.CleanVirtualStore + !verbose push + !verbose ${_MOZFUNC_VERBOSE} + !undef _MOZFUNC_UN + !define _MOZFUNC_UN "un." + + !insertmacro CleanVirtualStore + + !undef _MOZFUNC_UN + !define _MOZFUNC_UN + !verbose pop + !endif +!macroend