Make uninstaller cleaner again!!

Fixed uinstaller issues:
1. Folder "localization" is not removed even all the files are removed from
this folder.
2. Folder "pluging\APIs" is not removed even all the files are removed from
this folder.
3. Three files are not removed (contextMenu.xml, functionList.xml and
shortcuts.xml). There might be more files.
From "%appdata%\Notepad"
4. Bakcup folder (form %appdata%\Notepad++) is not removed if backup folder
is not empty.
5. Folder "themes" is not removed even all the files are removed.
6. Because of above two items, parent folder ("%appdata%\Notepad") is also
not removed.
7. Rephrase user message when user tries to install 64 bit while 32 is
already installed (vice versa).

Closes #2565
This commit is contained in:
SinghRajenM 2016-10-15 02:30:54 +05:30 committed by Don Ho
parent 855e581e44
commit c36ee6ec9a
2 changed files with 23 additions and 7 deletions

View File

@ -113,7 +113,7 @@ Function .onInit
; check if 32-bit version has been installed if yes, ask user to remove it ; check if 32-bit version has been installed if yes, ask user to remove it
IfFileExists $PROGRAMFILES\${APPNAME}\notepad++.exe 0 noDelete32 IfFileExists $PROGRAMFILES\${APPNAME}\notepad++.exe 0 noDelete32
MessageBox MB_YESNO "You're installing 64-bit version. 32-bit version has been installed. Remove it?$\n(Your custom config files will be kept)" /SD IDYES IDYES doDelete32 IDNO noDelete32 ;IDYES remove MessageBox MB_YESNO "You are trying to install 64-bit version while 32-bit version is already installed. Would you like to remove Notepad++ 32 bit version before proceeding further?$\n(Your custom config files will be kept)" /SD IDYES IDYES doDelete32 IDNO noDelete32 ;IDYES remove
doDelete32: doDelete32:
StrCpy $diffArchDir2Remove $PROGRAMFILES\${APPNAME} StrCpy $diffArchDir2Remove $PROGRAMFILES\${APPNAME}
noDelete32: noDelete32:
@ -126,7 +126,7 @@ noDelete32:
${If} ${RunningX64} ${If} ${RunningX64}
; check if 64-bit version has been installed if yes, ask user to remove it ; check if 64-bit version has been installed if yes, ask user to remove it
IfFileExists $PROGRAMFILES64\${APPNAME}\notepad++.exe 0 noDelete64 IfFileExists $PROGRAMFILES64\${APPNAME}\notepad++.exe 0 noDelete64
MessageBox MB_YESNO "You're installing 32-bit version. 64-bit version has been installed. Remove it?$\n(Your custom config files will be kept)" /SD IDYES IDYES doDelete64 IDNO noDelete64 MessageBox MB_YESNO "You are trying to install 32-bit version while 64-bit version is already installed. Would you like to remove Notepad++ 64 bit version before proceeding further?$\n(Your custom config files will be kept)" /SD IDYES IDYES doDelete64 IDNO noDelete64
doDelete64: doDelete64:
StrCpy $diffArchDir2Remove $PROGRAMFILES64\${APPNAME} StrCpy $diffArchDir2Remove $PROGRAMFILES64\${APPNAME}
noDelete64: noDelete64:

View File

@ -27,7 +27,9 @@
Var themesParentPath Var themesParentPath
Var doLocalConf Var doLocalConf
Var keepUserData
Function un.onInit Function un.onInit
StrCpy $keepUserData "false" ; default value(It is must, otherwise few files such as shortcuts.xml, contextMenu.xml etc, will not be removed when $INSTDIR\doLocalConf.xml is not avaliable.)
; determinate theme path for uninstall themes ; determinate theme path for uninstall themes
StrCpy $themesParentPath "$APPDATA\${APPNAME}" StrCpy $themesParentPath "$APPDATA\${APPNAME}"
StrCpy $doLocalConf "false" StrCpy $doLocalConf "false"
@ -39,6 +41,21 @@ noneExist:
;MessageBox MB_OK "doLocalConf == $doLocalConf" ;MessageBox MB_OK "doLocalConf == $doLocalConf"
FunctionEnd FunctionEnd
Function un.onUninstSuccess
; make sure all the empty folders are deleted on successful uninstall
; These folders will be deleted only if they are emtpy
RMDir "$INSTDIR\localization\"
RMDir "$INSTDIR\plugins\APIs\"
RMDir "$INSTDIR\plugins\disabled\"
RMDir "$INSTDIR\plugins\"
RMDir "$INSTDIR\updater\"
RMDir "$INSTDIR\"
RMDir "$APPDATA\${APPNAME}\plugins\"
RMDir "$themesParentPath\themes\" ; if files are kept because of $keepUserData, this will not be deleted
RMDir "$themesParentPath\"
FunctionEnd
Section un.explorerContextMenu Section un.explorerContextMenu
Exec 'regsvr32 /u /s "$INSTDIR\NppShell_01.dll"' Exec 'regsvr32 /u /s "$INSTDIR\NppShell_01.dll"'
@ -116,7 +133,6 @@ Section un.UserManual
SectionEnd SectionEnd
Var keepUserData
Function un.doYouReallyWantToKeepData Function un.doYouReallyWantToKeepData
StrCpy $keepUserData "false" StrCpy $keepUserData "false"
MessageBox MB_YESNO "Would you like to keep your custom settings?" /SD IDNO IDYES skipRemoveUserData IDNO removeUserData MessageBox MB_YESNO "Would you like to keep your custom settings?" /SD IDNO IDYES skipRemoveUserData IDNO removeUserData
@ -247,9 +263,9 @@ Section Uninstall
Delete "$APPDATA\${APPNAME}\insertExt.ini" Delete "$APPDATA\${APPNAME}\insertExt.ini"
RMDir /r "$APPDATA\${APPNAME}\plugins\" RMDir /r "$APPDATA\${APPNAME}\plugins\"
RMDir "$APPDATA\${APPNAME}\backup\" RMDir /r "$APPDATA\${APPNAME}\backup\" ; Remove backup folder recursively if not empty
RMDir "$APPDATA\${APPNAME}\themes\" RMDir "$APPDATA\${APPNAME}\themes\" ; has no effect as not empty at this momenet, but it is taken care at un.onUninstSuccess
RMDir "$APPDATA\${APPNAME}" RMDir "$APPDATA\${APPNAME}" ; has no effect as not empty at this momenet, but it is taken care at un.onUninstSuccess
StrCmp $1 "Admin" 0 +2 StrCmp $1 "Admin" 0 +2
SetShellVarContext all ; make context for all user SetShellVarContext all ; make context for all user