2021-01-23 03:23:47 +00:00
; This file is part of Notepad++ project
; Copyright (C)2021 Don HO <don.h@free.fr>
2016-09-21 18:55:10 +00:00
;
2021-01-23 03:23:47 +00:00
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; at your option any later version.
2016-09-21 18:55:10 +00:00
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
2021-01-23 03:23:47 +00:00
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2016-09-21 18:55:10 +00:00
; GNU General Public License for more details.
2021-01-23 03:23:47 +00:00
;
2016-09-21 18:55:10 +00:00
; You should have received a copy of the GNU General Public License
2021-01-23 03:23:47 +00:00
; along with this program. If not, see <https://www.gnu.org/licenses/>.
2016-09-09 21:26:15 +00:00
2019-03-03 02:12:27 +00:00
Var installPath
2016-10-04 15:58:08 +00:00
Var doLocalConf
2016-10-14 21:00:54 +00:00
Var keepUserData
2016-10-04 15:58:08 +00:00
Function un.onInit
2019-03-14 13:59:11 +00:00
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 available.)
2016-10-14 21:00:54 +00:00
; determinate theme path for uninstall themes
2019-03-03 02:12:27 +00:00
StrCpy $installPath "$APPDATA\${APPNAME}"
2016-10-04 15:58:08 +00:00
StrCpy $doLocalConf "false"
IfFileExists $INSTDIR\doLocalConf.xml doesExist noneExist
doesExist:
2019-03-03 02:12:27 +00:00
StrCpy $installPath $INSTDIR
2016-10-04 15:58:08 +00:00
StrCpy $doLocalConf "true"
noneExist:
;MessageBox MB_OK "doLocalConf == $doLocalConf"
2018-12-06 01:31:39 +00:00
Call un.setPathAndOptions
2016-10-04 15:58:08 +00:00
FunctionEnd
2016-10-14 21:00:54 +00:00
Function un.onUninstSuccess
; make sure all the empty folders are deleted on successful uninstall
2019-01-28 15:54:55 +00:00
; These folders will be deleted only if they are empty
2016-10-14 21:00:54 +00:00
RMDir "$INSTDIR\localization\"
RMDir "$INSTDIR\plugins\APIs\"
RMDir "$INSTDIR\plugins\disabled\"
RMDir "$INSTDIR\plugins\"
RMDir "$INSTDIR\updater\"
2019-03-14 13:59:11 +00:00
RMDir "$INSTDIR\autoCompletion\"
2023-03-19 23:37:44 +00:00
RMDir "$INSTDIR\functionList\"
RMDir "$INSTDIR\themes\"
2023-03-25 08:42:02 +00:00
RMDir "$INSTDIR\contextmenu\"
2016-10-14 21:00:54 +00:00
RMDir "$INSTDIR\"
RMDir "$APPDATA\${APPNAME}\plugins\"
2019-03-03 02:12:27 +00:00
RMDir "$installPath\themes\" ; if files are kept because of $keepUserData, this will not be deleted
2023-03-19 23:37:44 +00:00
RMDir "$installPath\userDefineLangs\"
2023-03-25 08:42:02 +00:00
RMDir "$installPath\contextmenu\"
2019-03-03 02:12:27 +00:00
RMDir "$installPath\"
2016-10-14 21:00:54 +00:00
FunctionEnd
2016-10-04 15:58:08 +00:00
2016-09-09 21:26:15 +00:00
Section un.explorerContextMenu
2023-04-11 15:59:38 +00:00
ExecWait 'regsvr32 /u /s "$INSTDIR\NppShell_01.dll"'
ExecWait 'regsvr32 /u /s "$INSTDIR\NppShell_02.dll"'
ExecWait 'regsvr32 /u /s "$INSTDIR\NppShell_03.dll"'
ExecWait 'regsvr32 /u /s "$INSTDIR\NppShell_04.dll"'
ExecWait 'regsvr32 /u /s "$INSTDIR\NppShell_05.dll"'
ExecWait 'regsvr32 /u /s "$INSTDIR\NppShell_06.dll"'
2016-09-09 21:26:15 +00:00
Delete "$INSTDIR\NppShell_01.dll"
Delete "$INSTDIR\NppShell_02.dll"
Delete "$INSTDIR\NppShell_03.dll"
Delete "$INSTDIR\NppShell_04.dll"
Delete "$INSTDIR\NppShell_05.dll"
Delete "$INSTDIR\NppShell_06.dll"
Add new explorer context menu entry "Edit with Notepad++" for W11
Windows 11 has its new interface for its explorer context menu. It makes the old "Edit with Notepad++" command hardly accessible. This commit improves the accessibility and also fix issue of run as an administrator (Properties set in Compatibility) in the new context menu command.
It fixes also the context menu command issue under ARM64 architecture (fixed only under Windows 11).
The localization of "Edit with Notepad++" is also possible in this commit.
Note that if the command place of "Edit with Notepad++" context menu command is taken by other application ("\HKEY_CLASSES_ROOT*\shell\pintohome"), the new context menu "Edit with Notepad++" won't be installed. User should install it him/herself.
Fix #10320, fix #10565, fix #4368, fix #8786, fix #10320, fix #10640, fix #10856, fix #10653, fix #7747, fix #6169, fix #92, close #13170
2023-02-18 16:43:24 +00:00
2023-04-11 15:59:38 +00:00
ExecWait 'regsvr32 /u /s "$INSTDIR\contextmenu\NppShell.dll"'
2016-09-09 21:26:15 +00:00
SectionEnd
Section un.UnregisterFileExt
; Remove references to "Notepad++_file"
IntOp $1 0 + 0 ; subkey index
StrCpy $2 "" ; subkey name
Enum_HKCR_Loop:
EnumRegKey $2 HKCR "" $1
StrCmp $2 "" Enum_HKCR_Done
ReadRegStr $0 HKCR $2 "" ; Read the default value
${If} $0 == "Notepad++_file"
ReadRegStr $3 HKCR $2 "Notepad++_backup"
; Recover (some of) the lost original file types
${If} $3 == "Notepad++_file"
${If} $2 == ".ini"
StrCpy $3 "inifile"
${ElseIf} $2 == ".inf"
StrCpy $3 "inffile"
${ElseIf} $2 == ".nfo"
StrCpy $3 "MSInfoFile"
${ElseIf} $2 == ".txt"
StrCpy $3 "txtfile"
${ElseIf} $2 == ".log"
StrCpy $3 "txtfile"
${ElseIf} $2 == ".xml"
StrCpy $3 "xmlfile"
${EndIf}
${EndIf}
${If} $3 == "Notepad++_file"
; File type recovering has failed. Just discard the current file extension
DeleteRegKey HKCR $2
${Else}
; Restore the original file type
WriteRegStr HKCR $2 "" $3
DeleteRegValue HKCR $2 "Notepad++_backup"
IntOp $1 $1 + 1
${EndIf}
${Else}
IntOp $1 $1 + 1
${EndIf}
Goto Enum_HKCR_Loop
Enum_HKCR_Done:
; Remove references to "Notepad++_file" from "Open with..."
IntOp $1 0 + 0 ; subkey index
StrCpy $2 "" ; subkey name
Enum_FileExts_Loop:
EnumRegKey $2 HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts" $1
StrCmp $2 "" Enum_FileExts_Done
DeleteRegValue HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$2\OpenWithProgids" "Notepad++_file"
IntOp $1 $1 + 1
Goto Enum_FileExts_Loop
Enum_FileExts_Done:
; Remove "Notepad++_file" file type
DeleteRegKey HKCR "Notepad++_file"
SectionEnd
Section un.UserManual
RMDir /r "$INSTDIR\user.manual"
SectionEnd
2016-10-06 07:37:25 +00:00
2016-10-04 15:58:08 +00:00
Function un.doYouReallyWantToKeepData
StrCpy $keepUserData "false"
2016-10-30 12:38:42 +00:00
MessageBox MB_YESNO "Would you like to keep your custom settings?" /SD IDNO IDYES skipRemoveUserData IDNO removeUserData
2016-10-04 15:58:08 +00:00
skipRemoveUserData:
StrCpy $keepUserData "true"
removeUserData:
FunctionEnd
2016-10-06 07:37:25 +00:00
!macro uninstallRegKey
;Remove from registry...
!ifdef ARCH64
SetRegView 32
2021-04-21 18:42:01 +00:00
!else ifdef ARCHARM64
SetRegView 32
2016-10-06 07:37:25 +00:00
!else
SetRegView 64
!endif
DeleteRegKey HKLM "${UNINSTALL_REG_KEY}"
2017-02-27 17:56:58 +00:00
DeleteRegKey HKLM "SOFTWARE\${APPNAME}"
2016-10-06 07:37:25 +00:00
;DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\notepad++.exe"
!ifdef ARCH64
SetRegView 64
2021-04-21 18:42:01 +00:00
!else ifdef ARCHARM64
SetRegView 64
2016-10-06 07:37:25 +00:00
!else
SetRegView 32
!endif
!macroend
!macro uninstallDir dir2remove
; Delete Shortcuts
Delete "$SMPROGRAMS\Notepad++\Uninstall.lnk"
RMDir "$SMPROGRAMS\Notepad++"
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +2
SetShellVarContext all
Delete "$DESKTOP\Notepad++.lnk"
2018-03-26 08:34:43 +00:00
Delete "$SMPROGRAMS\Notepad++.lnk"
2016-10-06 07:37:25 +00:00
Delete "$SMPROGRAMS\Notepad++\Notepad++.lnk"
Delete "$SMPROGRAMS\Notepad++\readme.lnk"
RMDir /r "${dir2remove}"
!macroend
2016-09-09 21:26:15 +00:00
Section Uninstall
2016-10-01 21:14:40 +00:00
!ifdef ARCH64
SetRegView 64
2021-04-21 18:42:01 +00:00
!else ifdef ARCHARM64
SetRegView 64
2016-10-01 21:14:40 +00:00
!else
SetRegView 32
!endif
2016-09-09 21:26:15 +00:00
;Remove from registry...
DeleteRegKey HKLM "${UNINSTALL_REG_KEY}"
DeleteRegKey HKLM "SOFTWARE\${APPNAME}"
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\notepad++.exe"
; Delete self
Delete "$INSTDIR\uninstall.exe"
; Delete Shortcuts
2016-10-02 12:38:17 +00:00
Delete "$SMPROGRAMS\${APPNAME}\Uninstall.lnk"
RMDir "$SMPROGRAMS\${APPNAME}"
2016-09-09 21:26:15 +00:00
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +2
2016-10-02 12:38:17 +00:00
SetShellVarContext all ; make context for all user
2016-09-09 21:26:15 +00:00
Delete "$DESKTOP\Notepad++.lnk"
2018-03-26 08:34:43 +00:00
Delete "$SMPROGRAMS\Notepad++.lnk"
2016-10-02 12:38:17 +00:00
Delete "$SMPROGRAMS\${APPNAME}\Notepad++.lnk"
Delete "$SMPROGRAMS\${APPNAME}\readme.lnk"
2016-09-09 21:26:15 +00:00
; Clean up Notepad++
Delete "$INSTDIR\SciLexer.dll"
Delete "$INSTDIR\change.log"
Delete "$INSTDIR\LICENSE"
Delete "$INSTDIR\notepad++.exe"
Delete "$INSTDIR\readme.txt"
2016-10-04 15:58:08 +00:00
${If} $doLocalConf == "true"
Call un.doYouReallyWantToKeepData
${endIf}
${If} $keepUserData == "false"
Delete "$INSTDIR\config.xml"
Delete "$INSTDIR\langs.xml"
Delete "$INSTDIR\stylers.xml"
Delete "$INSTDIR\contextMenu.xml"
2022-12-19 02:34:24 +00:00
Delete "$INSTDIR\tabContextMenu.xml"
2016-10-04 15:58:08 +00:00
Delete "$INSTDIR\shortcuts.xml"
Delete "$INSTDIR\functionList.xml"
Delete "$INSTDIR\session.xml"
Delete "$INSTDIR\nativeLang.xml"
Delete "$INSTDIR\userDefineLang.xml"
2021-12-02 02:55:24 +00:00
Delete "$INSTDIR\nppLogNulContentCorruptionIssue.xml"
2022-12-27 12:49:35 +00:00
Delete "$INSTDIR\toolbarIcons.xml"
2016-10-04 15:58:08 +00:00
${endIf}
2016-09-09 21:26:15 +00:00
Delete "$INSTDIR\config.model.xml"
Delete "$INSTDIR\langs.model.xml"
Delete "$INSTDIR\stylers.model.xml"
2022-12-19 02:34:24 +00:00
Delete "$INSTDIR\tabContextMenu_example.xml"
2016-09-09 21:26:15 +00:00
Delete "$INSTDIR\stylers_remove.xml"
Delete "$INSTDIR\localization\english.xml"
2016-10-04 15:58:08 +00:00
Delete "$INSTDIR\LINEDRAW.TTF"
2016-09-09 21:26:15 +00:00
Delete "$INSTDIR\SourceCodePro-Regular.ttf"
Delete "$INSTDIR\SourceCodePro-Bold.ttf"
Delete "$INSTDIR\SourceCodePro-It.ttf"
Delete "$INSTDIR\SourceCodePro-BoldIt.ttf"
2016-10-02 12:38:17 +00:00
Delete "$INSTDIR\NppHelp.chm"
2019-01-27 01:53:02 +00:00
Delete "$INSTDIR\userDefinedLang-markdown.default.modern.xml"
2019-03-03 02:12:27 +00:00
Delete "$INSTDIR\userDefineLangs\userDefinedLang-markdown.default.modern.xml"
2020-10-24 16:51:48 +00:00
Delete "$INSTDIR\userDefineLangs\markdown._preinstalled.udl.xml"
2021-08-06 20:59:40 +00:00
Delete "$INSTDIR\userDefineLangs\markdown._preinstalled_DM.udl.xml"
2016-10-04 15:58:08 +00:00
Delete "$INSTDIR\doLocalConf.xml"
2018-12-06 01:31:39 +00:00
Delete "$INSTDIR\uninstall.ini"
2016-09-09 21:26:15 +00:00
2016-10-04 15:58:08 +00:00
${If} $doLocalConf == "false"
Call un.doYouReallyWantToKeepData
${endIf}
2016-09-09 21:26:15 +00:00
2016-10-04 15:58:08 +00:00
${If} $keepUserData == "false"
; make context as current user to uninstall user's APPDATA
SetShellVarContext current
Delete "$APPDATA\${APPNAME}\langs.xml"
Delete "$APPDATA\${APPNAME}\config.xml"
Delete "$APPDATA\${APPNAME}\stylers.xml"
Delete "$APPDATA\${APPNAME}\contextMenu.xml"
Delete "$APPDATA\${APPNAME}\shortcuts.xml"
Delete "$APPDATA\${APPNAME}\functionList.xml"
Delete "$APPDATA\${APPNAME}\nativeLang.xml"
Delete "$APPDATA\${APPNAME}\session.xml"
Delete "$APPDATA\${APPNAME}\userDefineLang.xml"
Delete "$APPDATA\${APPNAME}\insertExt.ini"
2022-01-09 01:35:19 +00:00
Delete "$APPDATA\${APPNAME}\nppLogNulContentCorruptionIssue.log"
2023-05-13 23:04:11 +00:00
Delete "$APPDATA\${APPNAME}\tabContextMenu_example.xml"
2022-12-27 12:49:35 +00:00
Delete "$APPDATA\${APPNAME}\toolbarIcons.xml"
2019-03-03 02:12:27 +00:00
Delete "$APPDATA\${APPNAME}\userDefineLangs\userDefinedLang-markdown.default.modern.xml"
2020-10-24 16:51:48 +00:00
Delete "$APPDATA\${APPNAME}\userDefineLangs\markdown._preinstalled.udl.xml"
2021-08-06 20:59:40 +00:00
Delete "$APPDATA\${APPNAME}\userDefineLangs\markdown._preinstalled_DM.udl.xml"
2016-10-04 15:58:08 +00:00
RMDir /r "$APPDATA\${APPNAME}\plugins\"
2016-10-14 21:00:54 +00:00
RMDir /r "$APPDATA\${APPNAME}\backup\" ; Remove backup folder recursively if not empty
2019-03-14 13:59:11 +00:00
RMDir "$APPDATA\${APPNAME}\themes\" ; has no effect as not empty at this moment, but it is taken care at un.onUninstSuccess
RMDir "$APPDATA\${APPNAME}" ; has no effect as not empty at this moment, but it is taken care at un.onUninstSuccess
2016-09-09 21:26:15 +00:00
2016-10-04 15:58:08 +00:00
StrCmp $1 "Admin" 0 +2
SetShellVarContext all ; make context for all user
${endIf}
2023-03-19 23:37:44 +00:00
; In order to not delete context menu binary before we unregistered it,
2023-03-25 08:42:02 +00:00
; we delete them at the end, using the CleanupDll function, since it can be locked by explorer.
2023-05-13 22:43:33 +00:00
IfFileExists "$INSTDIR\contextmenu\NppShell.dll" 0 +2
ExecWait 'rundll32.exe "$INSTDIR\contextmenu\NppShell.dll",CleanupDll'
2023-03-25 08:42:02 +00:00
Delete "$INSTDIR\contextmenu\NppShell.msix"
2023-03-19 23:37:44 +00:00
2016-09-09 21:26:15 +00:00
; Remove remaining directories
RMDir /r "$INSTDIR\plugins\disabled\"
RMDir "$INSTDIR\plugins\APIs\"
RMDir "$INSTDIR\plugins\"
RMDir "$INSTDIR\themes\"
RMDir "$INSTDIR\localization\"
2022-01-09 01:35:19 +00:00
RMDir "$INSTDIR\functionList\"
2023-03-25 08:42:02 +00:00
RMDir "$INSTDIR\contextmenu\"
2016-09-09 21:26:15 +00:00
RMDir "$INSTDIR\"
2016-10-02 12:38:17 +00:00
RMDir "$SMPROGRAMS\${APPNAME}"
2016-09-09 21:26:15 +00:00
SectionEnd
2016-10-04 15:58:08 +00:00