From 77fcbeca270d35e7da6afb0df12efdfc726a065a Mon Sep 17 00:00:00 2001 From: dmiller Date: Mon, 13 Dec 2021 20:51:08 +0000 Subject: [PATCH] NSIS: disable Npcap install if installed version is newer or same. --- mswin32/nsis/Nmap.nsi | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mswin32/nsis/Nmap.nsi b/mswin32/nsis/Nmap.nsi index 7baa3b84e..5a486e908 100644 --- a/mswin32/nsis/Nmap.nsi +++ b/mswin32/nsis/Nmap.nsi @@ -39,6 +39,7 @@ !include "MUI.nsh" !include "AddToPath.nsh" !include "FileFunc.nsh" + !include "WordFunc.nsh" !include "Sections.nsh" ;-------------------------------- @@ -266,7 +267,7 @@ Section "Npcap ${NPCAP_VERSION}" SecNpcap SectionEnd !endif -Section /o "Check for newer Npcap" SecNewNpcap +Section /o "Check online for newer Npcap" SecNewNpcap ExecShell "open" "https://npcap.org/#download" SectionEnd @@ -422,6 +423,18 @@ Function .onInit !insertmacro MUI_INSTALLOPTIONS_EXTRACT "final.ini" + ; Check if Npcap is already installed. + ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NpcapInst" "DisplayVersion" + ${If} $0 != "" + ${VersionCompare} $0 ${NPCAP_VERSION} $1 + ; If our version is not newer than the installed version, don't offer to install Npcap. + ${If} $1 != 2 + SectionGetFlags ${SecNpcap} $2 + IntOp $2 $2 & ${SECTION_OFF} + SectionSetFlags ${SecNpcap} $2 + ${EndIf} + ${EndIf} + ;Disable section checkboxes based on options. For example /ZENMAP=NO to avoid ;installing Zenmap. ${GetParameters} $0