From 1be0044663df209e7044d413532672ccbba7d1a3 Mon Sep 17 00:00:00 2001 From: xomx Date: Fri, 14 Oct 2022 17:51:00 +0200 Subject: [PATCH] Installer enhancement: prevent arm64 installer from installing on non ARM64 system Fix #12320, close #12331 --- PowerEditor/installer/nppSetup.nsi | 2 +- PowerEditor/installer/nsisInclude/tools.nsh | 30 +++++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/PowerEditor/installer/nppSetup.nsi b/PowerEditor/installer/nppSetup.nsi index e3cec1602..1a7148a1e 100644 --- a/PowerEditor/installer/nppSetup.nsi +++ b/PowerEditor/installer/nppSetup.nsi @@ -172,7 +172,7 @@ updaterDone: Call SetRoughEstimation ; This is rough estimation of files present in function copyCommonFiles InitPluginsDir ; Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized. - Call preventInstallInWin9x + Call checkCompatibility ; check unsupported OSes and CPUs ; look for previously selected language ClearErrors diff --git a/PowerEditor/installer/nsisInclude/tools.nsh b/PowerEditor/installer/nsisInclude/tools.nsh index f7ae0af80..8cfb3350f 100644 --- a/PowerEditor/installer/nsisInclude/tools.nsh +++ b/PowerEditor/installer/nsisInclude/tools.nsh @@ -124,28 +124,28 @@ Function ExtraOptions nsDialogs::Show FunctionEnd -Function preventInstallInWin9x - ;Test if window9x +Function checkCompatibility + ${GetWindowsVersion} $WinVer StrCmp $WinVer "95" 0 +3 - MessageBox MB_OK "Notepad++ does not support your OS. The installation will be aborted." + MessageBox MB_OK|MB_ICONSTOP "Notepad++ does not support your OS. The installation will be aborted." Abort StrCmp $WinVer "98" 0 +3 - MessageBox MB_OK "Notepad++ does not support your OS. The installation will be aborted." + MessageBox MB_OK|MB_ICONSTOP "Notepad++ does not support your OS. The installation will be aborted." Abort StrCmp $WinVer "ME" 0 +3 - MessageBox MB_OK "Notepad++ does not support your OS. The installation will be aborted." + MessageBox MB_OK|MB_ICONSTOP "Notepad++ does not support your OS. The installation will be aborted." Abort StrCmp $WinVer "2000" 0 +3 ; Windows 2000 - MessageBox MB_OK "Notepad++ does not support your OS. The installation will be aborted." + MessageBox MB_OK|MB_ICONSTOP "Notepad++ does not support your OS. The installation will be aborted." Abort StrCmp $WinVer "XP" 0 xp_endTest ; XP - MessageBox MB_YESNO "This version of Notepad++ doesn't support Windows XP. The installation will be aborted.$\nDo you want to go to Notepad++ download page for downloading the last version which supports XP (v7.9.2)?" IDYES xp_openDlPage IDNO xp_goQuit + MessageBox MB_YESNO|MB_ICONSTOP "This version of Notepad++ doesn't support Windows XP. The installation will be aborted.$\n$\nDo you want to go to Notepad++ download page for downloading the last version which supports XP (v7.9.2)?" IDYES xp_openDlPage IDNO xp_goQuit xp_openDlPage: ExecShell "open" "https://notepad-plus-plus.org/downloads/v7.9.2/" xp_goQuit: @@ -153,12 +153,26 @@ xp_goQuit: xp_endTest: StrCmp $WinVer "2003" 0 ws2003_endTest ; Windows Server 2003 - MessageBox MB_YESNO "This version of Notepad++ doesn't support Windows Server 2003. The installation will be aborted.$\nDo you want to go to Notepad++ download page for downloading the last version which supports this OS?" IDYES ws2003_openDlPage IDNO ws2003_goQuit + MessageBox MB_YESNO|MB_ICONSTOP "This version of Notepad++ doesn't support Windows Server 2003. The installation will be aborted.$\n$\nDo you want to go to Notepad++ download page for downloading the last version which supports this OS?" IDYES ws2003_openDlPage IDNO ws2003_goQuit ws2003_openDlPage: ExecShell "open" "https://notepad-plus-plus.org/downloads/v7.9.2/" ws2003_goQuit: Abort ws2003_endTest: + +!ifdef ARCHARM64 + ${If} ${IsNativeARM64} + ; OK + ${Else} + ; we cannot run ARM64 binaries on a x86/x64 CPU (the other way around is possible - x86 on ARM64 CPU) + MessageBox MB_YESNO|MB_ICONSTOP "This installer contains ARM64 version of Notepad++ incompatible with your computer processor running, so the installation will be aborted.$\n$\nDo you want to go to the Notepad++ site to download a compatible (x86/x64) installer instead?" IDYES arm64_openDlPage IDNO arm64_goQuit +arm64_openDlPage: + ExecShell "open" "https://notepad-plus-plus.org/downloads/" +arm64_goQuit: + Abort + ${EndIf} +!endif + FunctionEnd