Detect a previous Wireshark installation and let the user uninstall it first.
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 21 Oct 2008 16:44:35 +0000 (16:44 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 21 Oct 2008 16:44:35 +0000 (16:44 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@26509 f5534014-38df-0310-8fa8-9805f1628bb7

packaging/nsis/wireshark.nsi

index 59ed1d80bde673ff2b21e1de815289c5b818cf4e..4f6ab7d3942f7f2728464e2e3e9398b63a5c4521 100644 (file)
@@ -261,7 +261,33 @@ un.unlink.end:
        pop $R1
 FunctionEnd
 
+Var OLD_UNINSTALLER
+Var OLD_DISPLAYNAME
+
 Function .onInit
+  ; Copied from http://nsis.sourceforge.net/Auto-uninstall_old_before_installing_new
+  ReadRegStr $OLD_UNINSTALLER HKLM \
+  "Software\Microsoft\Windows\CurrentVersion\Uninstall\Wireshark" \
+  "UninstallString"
+  StrCmp $OLD_UNINSTALLER "" done
+
+  ReadRegStr $OLD_DISPLAYNAME HKLM \
+  "Software\Microsoft\Windows\CurrentVersion\Uninstall\Wireshark" \
+  "DisplayName"
+  StrCmp $OLD_DISPLAYNAME "" done
+
+  MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
+  "$OLD_DISPLAYNAME is already installed. $\n$\nClick `OK` to remove it \
+  or `Cancel` to cancel this upgrade." \
+  IDOK uninst
+  Abort
+;Run the uninstaller
+uninst:
+  ClearErrors
+  ExecWait $OLD_UNINSTALLER
+  
+done:
   ;Extract InstallOptions INI files
   !insertmacro MUI_INSTALLOPTIONS_EXTRACT "AdditionalTasksPage.ini"
   !insertmacro MUI_INSTALLOPTIONS_EXTRACT "WinpcapPage.ini"
@@ -1138,25 +1164,6 @@ Var WINPCAP_VERSION ; DisplayVersion from WinPcap installation
 
 Function myShowCallback
 
-; Uinstall old Wireshark first
-; XXX - doesn't work, but kept here for further experiments
-;ReadRegStr $WIRESHARK_UNINSTALL HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Wireshark" "UninstallString"
-;IfErrors lbl_wireshark_notinstalled ;if RegKey is unavailable, WinPcap is not installed
-;MessageBox MB_YESNO|MB_ICONQUESTION "Uninstall the old Wireshark version first (recommended)?"
-; Hide the installer while uninstalling
-;GetDlgItem $0 $HWNDPARENT 1
-;FindWindow $0 "#32770" "" $HWNDPARENT
-;MessageBox MB_OK "Window $0"
-;ShowWindow $0 ${SW_HIDE}
-;HideWindow
-;ExecWait '$WIRESHARK_UNINSTALL' $0
-;DetailPrint "WinPcap uninstaller returned $0"
-;GetDlgItem $0 $HWNDPARENT 1
-;ShowWindow $0 ${SW_SHOW}
-;MessageBox MB_OK "Uninstalled"
-;lbl_wireshark_notinstalled:
-
-
        ; Get the Windows version
        Call GetWindowsVersion
        Pop $R0 ; Windows Version