2021-01-23 03:23:47 +00:00
; This file is part of Notepad++ project
; Copyright (C)2021 Don HO <don.h@free.fr>
2009-04-24 23:34:47 +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.
2009-04-24 23:34:47 +00:00
;
2012-04-17 23:35:01 +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
2012-04-17 23:35:01 +00:00
; GNU General Public License for more details.
2021-01-23 03:23:47 +00:00
;
2012-04-17 23:35:01 +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/>.
2009-04-24 23:34:47 +00:00
2015-02-12 00:46:14 +00:00
; NSIS includes
!include "x64.nsh" ; a few simple macros to handle installations on x64 machines
!include "MUI.nsh" ; Modern UI
!include "nsDialogs.nsh" ; allows creation of custom pages in the installer
!include "Memento.nsh" ; remember user selections in the installer across runs
2016-11-18 15:32:05 +00:00
!include "FileFunc.nsh"
2015-02-12 00:46:14 +00:00
2016-11-14 18:16:16 +00:00
Unicode true ; Generate a Unicode installer. It can only be used outside of sections and functions and before any data is compressed.
2016-08-15 09:10:18 +00:00
SetCompressor /SOLID lzma ; This reduces installer size by approx 30~35%
2016-09-09 21:26:15 +00:00
;SetCompressor /FINAL lzma ; This reduces installer size by approx 15~18%
2015-02-12 00:46:14 +00:00
2018-10-22 23:52:41 +00:00
; Installer is DPI-aware: not scaled by the DWM, no blurry text
ManifestDPIAware true
2016-09-09 21:26:15 +00:00
!include "nsisInclude\winVer.nsh"
2016-11-14 00:11:53 +00:00
!include "nsisInclude\globalDef.nsh"
2016-09-16 02:11:27 +00:00
!include "nsisInclude\tools.nsh"
2016-10-06 07:37:25 +00:00
!include "nsisInclude\uninstall.nsh"
2009-04-24 23:34:47 +00:00
2016-09-09 21:26:15 +00:00
!ifdef ARCH64
OutFile ".\build\npp.${APPVERSION}.Installer.x64.exe"
2021-04-21 18:42:01 +00:00
!else ifdef ARCHARM64
OutFile ".\build\npp.${APPVERSION}.Installer.arm64.exe"
2016-09-09 21:26:15 +00:00
!else
2016-09-21 18:55:10 +00:00
OutFile ".\build\npp.${APPVERSION}.Installer.exe"
2015-11-20 05:25:58 +00:00
!endif
2017-09-18 18:52:34 +00:00
; ------------------------------------------------------------------------
; Version Information
VIProductVersion "${Version}"
VIAddVersionKey "ProductName" "${APPNAME}"
VIAddVersionKey "CompanyName" "${CompanyName}"
VIAddVersionKey "LegalCopyright" "${LegalCopyright}"
VIAddVersionKey "FileDescription" "${Description}"
VIAddVersionKey "FileVersion" "${Version}"
VIAddVersionKey "ProductVersion" "${ProdVer}"
; ------------------------------------------------------------------------
2016-05-22 14:12:22 +00:00
; Insert CheckIfRunning function as an installer and uninstaller function.
!insertmacro CheckIfRunning ""
!insertmacro CheckIfRunning "un."
2009-04-24 23:34:47 +00:00
; Modern interface settings
!define MUI_ICON ".\images\npp_inst.ico"
2017-02-14 18:33:05 +00:00
!define MUI_UNICON ".\images\npp_inst.ico"
2009-04-24 23:34:47 +00:00
2019-01-27 22:13:30 +00:00
!define MUI_WELCOMEFINISHPAGE_BITMAP ".\images\wizard.bmp"
;!define MUI_WELCOMEFINISHPAGE_BITMAP ".\images\wizard_GiletJaune.bmp"
2019-01-01 01:46:17 +00:00
2009-04-24 23:34:47 +00:00
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP ".\images\headerLeft.bmp" ; optional
2018-01-20 05:01:28 +00:00
!define MUI_HEADERIMAGE_BITMAP_RTL ".\images\headerLeft_RTL.bmp" ; Header for RTL languages
2009-04-24 23:34:47 +00:00
!define MUI_ABORTWARNING
2017-09-16 03:25:50 +00:00
!define MUI_COMPONENTSPAGE_SMALLDESC ;Show components page with a small description and big box for components
2009-04-24 23:34:47 +00:00
!insertmacro MUI_PAGE_WELCOME
2015-05-08 17:39:51 +00:00
!insertmacro MUI_PAGE_LICENSE "..\..\LICENSE"
2009-04-24 23:34:47 +00:00
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
2011-05-31 00:04:49 +00:00
page Custom ExtraOptions
2016-05-22 14:12:22 +00:00
!define MUI_PAGE_CUSTOMFUNCTION_SHOW "CheckIfRunning"
2009-04-24 23:34:47 +00:00
!insertmacro MUI_PAGE_INSTFILES
2010-11-23 01:01:06 +00:00
2009-04-24 23:34:47 +00:00
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchNpp"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
2016-05-22 14:12:22 +00:00
!define MUI_PAGE_CUSTOMFUNCTION_SHOW "un.CheckIfRunning"
2009-04-24 23:34:47 +00:00
!insertmacro MUI_UNPAGE_INSTFILES
2017-01-30 15:06:26 +00:00
!include "nsisInclude\langs4Installer.nsh"
2013-03-17 23:31:02 +00:00
2017-07-13 06:46:44 +00:00
!include "nsisInclude\mainSectionFuncs.nsh"
2018-11-04 21:21:04 +00:00
Section -"setPathAndOptionsSection" setPathAndOptionsSection
Call setPathAndOptions
SectionEnd
2017-07-13 06:46:44 +00:00
!include "nsisInclude\autoCompletion.nsh"
2017-12-04 19:00:55 +00:00
2020-10-11 00:24:15 +00:00
!include "nsisInclude\functionList.nsh"
2018-11-04 21:21:04 +00:00
2017-07-13 06:46:44 +00:00
!include "nsisInclude\binariesComponents.nsh"
InstType "Minimalist"
2016-10-06 07:37:25 +00:00
Var diffArchDir2Remove
2017-07-13 06:46:44 +00:00
Var noUpdater
2018-11-24 16:30:19 +00:00
2022-02-08 20:31:28 +00:00
!ifdef ARCH64 || ARCHARM64
; this is needed for the 64-bit InstallDirRegKey patch
!include "StrFunc.nsh"
${StrStr} # Supportable for Install Sections and Functions
!endif
2009-04-24 23:34:47 +00:00
Function .onInit
2022-02-08 20:31:28 +00:00
; --- PATCH BEGIN (it can be deleted without side-effects, when the NSIS N++ x64 installer binary becomes x64 too)---
;
; 64-bit patch for the NSIS attribute InstallDirRegKey (used in globalDef.nsh)
; - this is needed because of the NSIS binary, generated for 64-bit Notepad++ installations, is still a 32-bit app,
; so the InstallDirRegKey checks for the irrelevant HKLM\SOFTWARE\WOW6432Node\Notepad++, explanation:
; https://nsis.sourceforge.io/Reference/SetRegView
;
!ifdef ARCH64 || ARCHARM64
${If} ${RunningX64}
System::Call kernel32::GetCommandLine()t.r0 ; get the original cmdline (where a possible "/D=..." is not hidden from us by NSIS)
${StrStr} $1 $0 "/D="
${If} "$1" == ""
; "/D=..." was NOT used for sure, so we can continue in this InstallDirRegKey x64 patch
SetRegView 64 ; disable registry redirection
ReadRegStr $0 HKLM "Software\${APPNAME}" ""
${If} "$0" != ""
; a previous installation path has been detected, so offer that as the $INSTDIR
StrCpy $INSTDIR "$0"
${EndIf}
SetRegView 32 ; restore the original state
${EndIf}
${EndIf}
!endif
;
; --- PATCH END ---
2017-07-09 06:58:44 +00:00
${GetParameters} $R0
2017-07-13 06:46:44 +00:00
${GetOptions} $R0 "/noUpdater" $R1 ;case insensitive
IfErrors withUpdater withoutUpdater
withUpdater:
StrCpy $noUpdater "false"
Goto updaterDone
withoutUpdater:
StrCpy $noUpdater "true"
updaterDone:
2018-11-06 12:31:20 +00:00
${If} $noUpdater == "true"
!insertmacro UnSelectSection ${AutoUpdater}
SectionSetText ${AutoUpdater} ""
!insertmacro UnSelectSection ${PluginsAdmin}
SectionSetText ${PluginsAdmin} ""
${EndIf}
2018-11-24 16:30:19 +00:00
2018-11-06 12:31:20 +00:00
${If} ${SectionIsSelected} ${PluginsAdmin}
!insertmacro SetSectionFlag ${AutoUpdater} ${SF_RO}
!insertmacro SelectSection ${AutoUpdater}
${Else}
!insertmacro ClearSectionFlag ${AutoUpdater} ${SF_RO}
${EndIf}
2017-07-13 06:46:44 +00:00
2017-12-28 16:28:57 +00:00
Call SetRoughEstimation ; This is rough estimation of files present in function copyCommonFiles
2016-10-14 21:55:13 +00:00
InitPluginsDir ; Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
2022-10-14 15:51:00 +00:00
Call checkCompatibility ; check unsupported OSes and CPUs
2009-04-24 23:34:47 +00:00
2022-04-07 11:15:34 +00:00
; look for previously selected language
ClearErrors
Var /GLOBAL tempLng
ReadRegStr $tempLng HKLM "SOFTWARE\${APPNAME}" 'InstallerLanguage'
${IfNot} ${Errors}
2022-04-19 14:24:42 +00:00
StrCpy $LANGUAGE "$tempLng" ; set default language
2022-04-07 11:15:34 +00:00
${EndIf}
2016-10-06 07:37:25 +00:00
!insertmacro MUI_LANGDLL_DISPLAY
2009-04-24 23:34:47 +00:00
2022-04-07 11:15:34 +00:00
; save selected language to registry
WriteRegStr HKLM "SOFTWARE\${APPNAME}" 'InstallerLanguage' '$Language'
2021-04-22 00:47:18 +00:00
!ifdef ARCH64 || ARCHARM64 ; x64 or ARM64
2016-09-09 21:26:15 +00:00
${If} ${RunningX64}
; disable registry redirection (enable access to 64-bit portion of registry)
SetRegView 64
2016-10-06 07:37:25 +00:00
2016-11-14 00:11:53 +00:00
; change to x64 install dir if needed
${If} "$InstDir" != ""
${If} "$InstDir" == "$PROGRAMFILES\${APPNAME}"
StrCpy $INSTDIR "$PROGRAMFILES64\${APPNAME}"
${EndIf}
; else /D was used or last installation is not "$PROGRAMFILES\${APPNAME}"
${Else}
StrCpy $INSTDIR "$PROGRAMFILES64\${APPNAME}"
${EndIf}
2016-10-06 07:37:25 +00:00
; check if 32-bit version has been installed if yes, ask user to remove it
IfFileExists $PROGRAMFILES\${APPNAME}\notepad++.exe 0 noDelete32
2016-10-14 21:00:54 +00:00
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
2016-10-06 07:37:25 +00:00
doDelete32:
StrCpy $diffArchDir2Remove $PROGRAMFILES\${APPNAME}
noDelete32:
2016-09-09 21:26:15 +00:00
${Else}
2017-07-09 14:50:29 +00:00
MessageBox MB_OK "You cannot install Notepad++ 64-bit version on your 32-bit system.$\nPlease download and install Notepad++ 32-bit version instead."
2016-09-09 21:26:15 +00:00
Abort
${EndIf}
2021-04-22 00:47:18 +00:00
2016-10-06 07:37:25 +00:00
!else ; 32-bit installer
${If} ${RunningX64}
; check if 64-bit version has been installed if yes, ask user to remove it
IfFileExists $PROGRAMFILES64\${APPNAME}\notepad++.exe 0 noDelete64
2016-10-14 21:00:54 +00:00
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
2016-10-06 07:37:25 +00:00
doDelete64:
StrCpy $diffArchDir2Remove $PROGRAMFILES64\${APPNAME}
noDelete64:
${EndIf}
2016-09-09 21:26:15 +00:00
!endif
2009-04-24 23:34:47 +00:00
2015-02-12 00:46:14 +00:00
${MementoSectionRestore}
FunctionEnd
2017-09-02 12:57:59 +00:00
Section -"Notepad++" mainSection
${If} $diffArchDir2Remove != ""
!insertmacro uninstallRegKey
!insertmacro uninstallDir $diffArchDir2Remove
${endIf}
Call copyCommonFiles
Call removeUnstablePlugins
Call removeOldContextMenu
2018-11-24 16:30:19 +00:00
2017-09-02 12:57:59 +00:00
Call shortcutLinkManagement
2018-11-24 16:30:19 +00:00
2017-09-02 12:57:59 +00:00
SectionEnd
2017-12-28 16:28:57 +00:00
; Please **DONOT** move this function (SetRoughEstimation) anywhere else
; Just keep it right after the "mainSection" section
; Otherwise rough estimation for copyCommonFiles will not be set
; which will become reason for showing 0.0KB size on components section page
Function SetRoughEstimation
SectionSetSize ${mainSection} 4500 ; This is rough estimation of files present in function copyCommonFiles
FunctionEnd
!include "nsisInclude\langs4Npp.nsh"
2017-12-04 19:00:55 +00:00
!include "nsisInclude\themes.nsh"
${MementoSection} "Context Menu Entry" explorerContextMenu
SetOverwrite try
SetOutPath "$INSTDIR\"
; There is no need to keep x86 NppShell_06.dll in 64 bit installer
; But in 32bit installer both the Dlls are required
2021-04-21 18:42:01 +00:00
; As user can install 32bit npp version on x64 bit machine, that time x64 bit NppShell is required.
2017-12-04 19:00:55 +00:00
!ifdef ARCH64
File /oname=$INSTDIR\NppShell_06.dll "..\bin\NppShell64_06.dll"
2021-04-21 18:42:01 +00:00
!else ifdef ARCHARM64
File /oname=$INSTDIR\NppShell_06.dll "..\binarm64\NppShell64.dll"
2017-12-04 19:00:55 +00:00
!else
${If} ${RunningX64}
File /oname=$INSTDIR\NppShell_06.dll "..\bin\NppShell64_06.dll"
${Else}
File "..\bin\NppShell_06.dll"
${EndIf}
!endif
Exec 'regsvr32 /s "$INSTDIR\NppShell_06.dll"'
${MementoSectionEnd}
${MementoSectionDone}
;--------------------------------
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${explorerContextMenu} 'Explorer context menu entry for Notepad++ : Open whatever you want in Notepad++ from Windows Explorer.'
!insertmacro MUI_DESCRIPTION_TEXT ${autoCompletionComponent} 'Install the API files you need for the auto-completion feature (Ctrl+Space).'
2020-10-11 00:24:15 +00:00
!insertmacro MUI_DESCRIPTION_TEXT ${functionListComponent} 'Install the function list files you need for the function list feature (Ctrl+Space).'
2017-12-04 19:00:55 +00:00
!insertmacro MUI_DESCRIPTION_TEXT ${Plugins} 'You may need these plugins to extend the capabilities of Notepad++.'
2021-10-29 13:18:25 +00:00
!insertmacro MUI_DESCRIPTION_TEXT ${NppExport} 'Copy your syntax highlighted source code as HTML/RTF into clipboard, or save them as HTML/RTF files.'
!insertmacro MUI_DESCRIPTION_TEXT ${MimeTools} 'Encode/decode selected text with Base64, Quoted-printable, URL encoding, and SAML.'
!insertmacro MUI_DESCRIPTION_TEXT ${Converter} 'Convert ASCII to binary, octal, hexadecimal and decimal string.'
2017-12-04 19:00:55 +00:00
!insertmacro MUI_DESCRIPTION_TEXT ${localization} 'To use Notepad++ in your favorite language(s), install all/desired language(s).'
!insertmacro MUI_DESCRIPTION_TEXT ${Themes} 'The eye-candy to change visual effects. Use Theme selector to switch among them.'
!insertmacro MUI_DESCRIPTION_TEXT ${AutoUpdater} 'Keep Notepad++ updated: Automatically download and install the latest updates.'
2018-11-06 12:31:20 +00:00
!insertmacro MUI_DESCRIPTION_TEXT ${PluginsAdmin} 'Install, Update and Remove any plugin from a list by some clicks. It needs Auto-Updater installed.'
2017-12-04 19:00:55 +00:00
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
2017-09-02 12:57:59 +00:00
2018-11-06 12:31:20 +00:00
2015-02-12 00:46:14 +00:00
Function .onInstSuccess
${MementoSectionSave}
2009-04-24 23:34:47 +00:00
FunctionEnd
2017-09-16 03:25:50 +00:00
2017-12-28 16:28:57 +00:00
; Keep "FinishSection" section in the last so that
; writing installation info happens in the last
; Specially for writing registry "EstimatedSize"
; which is visible in control panel in column named "size"
Section -FinishSection
Call writeInstallInfoInRegistry
SectionEnd
2019-10-27 00:22:56 +00:00
BrandingText "Software is like sex: It's better when it's free"
2009-04-24 23:34:47 +00:00
; eof