mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 05:01:29 +00:00
Catch installs to a dir with an existing install in it
This commit is contained in:
@@ -373,8 +373,7 @@ OptionDisableSection_keep_${ID}:
|
|||||||
!undef ID
|
!undef ID
|
||||||
!macroend
|
!macroend
|
||||||
|
|
||||||
!ifdef NMAP_OEM
|
Function _GetFileVersionProductName
|
||||||
Function GetFileVersionProductName
|
|
||||||
System::Store S ; Stash registers
|
System::Store S ; Stash registers
|
||||||
Pop $R0 ; file path
|
Pop $R0 ; file path
|
||||||
Push "" ; return value (bad)
|
Push "" ; return value (bad)
|
||||||
@@ -398,7 +397,12 @@ Function GetFileVersionProductName
|
|||||||
${EndIf}
|
${EndIf}
|
||||||
System::Store L ; Restore registers
|
System::Store L ; Restore registers
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
!endif
|
!macro GetFileVersionProductName _file _outvar
|
||||||
|
Push ${_file}
|
||||||
|
Call _GetFileVersionProductName
|
||||||
|
Pop ${_outvar}
|
||||||
|
!macroend
|
||||||
|
!define GetFileVersionProductName "!insertmacro GetFileVersionProductName"
|
||||||
|
|
||||||
!macro stripQuotes string
|
!macro stripQuotes string
|
||||||
Push $R0
|
Push $R0
|
||||||
@@ -482,6 +486,8 @@ Function .onInit
|
|||||||
StrCpy $1 ""
|
StrCpy $1 ""
|
||||||
; $2 = old version
|
; $2 = old version
|
||||||
StrCpy $2 ""
|
StrCpy $2 ""
|
||||||
|
; $3 = old product name
|
||||||
|
StrCpy $3 ""
|
||||||
ReadRegStr $0 HKLM "${NMAP_UNINSTALL_KEY}" "UninstallString"
|
ReadRegStr $0 HKLM "${NMAP_UNINSTALL_KEY}" "UninstallString"
|
||||||
StrCmp $0 "" 0 old_install
|
StrCmp $0 "" 0 old_install
|
||||||
|
|
||||||
@@ -492,10 +498,8 @@ Function .onInit
|
|||||||
StrCmp $0 "" set_instdir
|
StrCmp $0 "" set_instdir
|
||||||
; Ok, so what is actually installed there?
|
; Ok, so what is actually installed there?
|
||||||
!insertmacro stripQuotes $0
|
!insertmacro stripQuotes $0
|
||||||
Push $0
|
${GetFileVersionProductName} $0 $3
|
||||||
Call GetFileVersionProductName
|
StrCmp $3 "${NMAP_NAME}" 0 set_instdir
|
||||||
Pop $2
|
|
||||||
StrCmp $2 "${NMAP_NAME}" 0 set_instdir
|
|
||||||
; Ok, it's a screwed-up install. We need to fix it up first.
|
; Ok, it's a screwed-up install. We need to fix it up first.
|
||||||
; Finish getting the old install info
|
; Finish getting the old install info
|
||||||
ReadRegStr $2 HKLM "${REG_UNINSTALL_KEY}\Nmap" "DisplayVersion"
|
ReadRegStr $2 HKLM "${REG_UNINSTALL_KEY}\Nmap" "DisplayVersion"
|
||||||
@@ -526,13 +530,22 @@ old_install:
|
|||||||
${GetParent} $0 $1
|
${GetParent} $0 $1
|
||||||
|
|
||||||
get_old_version:
|
get_old_version:
|
||||||
|
StrCpy $3 "${NMAP_NAME}"
|
||||||
StrCmp $2 "" 0 try_uninstall
|
StrCmp $2 "" 0 try_uninstall
|
||||||
ReadRegStr $2 HKLM "${NMAP_UNINSTALL_KEY}" "DisplayVersion"
|
ReadRegStr $2 HKLM "${NMAP_UNINSTALL_KEY}" "DisplayVersion"
|
||||||
StrCmp $2 "" 0 try_uninstall
|
StrCmp $2 "" 0 try_uninstall
|
||||||
StrCpy $2 "(unknown version)"
|
StrCpy $2 "(unknown version)"
|
||||||
|
|
||||||
try_uninstall:
|
try_uninstall:
|
||||||
MessageBox MB_YESNOCANCEL|MB_ICONQUESTION "${NMAP_NAME} $2 is already installed. $\n$\nWould you like to uninstall it first?" /SD IDYES IDYES run_uninstaller IDNO set_instdir
|
StrCpy $4 "try_uninstall"
|
||||||
|
${If} ${Silent}
|
||||||
|
; In silent mode, don't automatically run an uninstaller that's not Nmap.
|
||||||
|
StrCpy $5 $3 4
|
||||||
|
StrCmp $5 "Nmap" 0 set_instdir
|
||||||
|
${EndIf}
|
||||||
|
MessageBox MB_YESNOCANCEL|MB_ICONQUESTION \
|
||||||
|
'$3 $2 is already installed in "$1". $\n$\nWould you like to uninstall it first?' \
|
||||||
|
/SD IDYES IDYES run_uninstaller IDNO set_instdir
|
||||||
Abort
|
Abort
|
||||||
|
|
||||||
run_uninstaller:
|
run_uninstaller:
|
||||||
@@ -550,7 +563,18 @@ set_instdir:
|
|||||||
${Else}
|
${Else}
|
||||||
StrCpy $INSTDIR "$PROGRAMFILES\${NMAP_NAME}"
|
StrCpy $INSTDIR "$PROGRAMFILES\${NMAP_NAME}"
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
; If we didn't already try to uninstall, check to see if there's something in
|
||||||
|
; $INSTDIR that needs to be uninstalled.
|
||||||
|
${If} $4 <> "try_uninstall"
|
||||||
|
${AndIf} ${FileExists} "$INSTDIR\Uninstall.exe"
|
||||||
|
StrCpy $0 "$INSTDIR\Uninstall.exe"
|
||||||
|
StrCpy $1 $INSTDIR
|
||||||
|
${GetFileVersion} $0 $2
|
||||||
|
${GetFileVersionProductName} $0 $3
|
||||||
|
goto try_uninstall
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user