Remove Kleowrap and Gpgwrap
[gpg4win.git] / src / inst-gpg4win.nsi
index 0e63295..6b530a9 100644 (file)
@@ -24,6 +24,24 @@ Section "-gpg4win" SEC_gpg4win
   SetOutPath "$INSTDIR"
   File "${BUILD_DIR}/../gpg4win-${VERSION}.tar.bz2"
 !else
+
+# Uninstall an old version if found.
+  ClearErrors
+  ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPG4Win" "DisplayVersion"
+  IfErrors skip_uninst 0
+  StrCmp $0 "" skip_uninst
+  DetailPrint  "$(T_UninstallingOldVersion)$0"
+  ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPG4Win" "UninstallString"
+  IfErrors skip_uninst 0
+  ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GPG4Win" "InstallLocation"
+  IfErrors skip_uninst 0
+
+  ExecWait '$0 /S _?=$1'
+# Deleting here does not work?
+  Delete /REBOOTOK "$1\gpg4win-uninstall.exe"
+  RmDir "$1"
+
+skip_uninst:
   SetOutPath "$INSTDIR\share\gpg4win"
 
   File "${BUILD_DIR}/README.en.txt"
@@ -48,14 +66,10 @@ Section "-gpg4win" SEC_gpg4win
   FileClose $0
   DetailPrint "VERSION closed"
 
-  # Register the install directory for the GnuPG suite.
-  WriteRegStr HKLM "Software\GNU\GnuPG" "Install Directory" $INSTDIR
+  # Register the install directory for Gpg4win suite.
+  WriteRegStr HKLM "Software\${PRETTY_PACKAGE_SHORT}" "Install Directory" $INSTDIR
   DetailPrint "Saved install directory in the registry"
 
-  # Also write it to be recalled on new installation.  Currently
-  # disabled.
-  # WriteRegStr HKLM "Software\GNU\${PRETTY_PACKAGE_SHORT}" "Install Directory" $INSTDIR
-
   # We used to determine the language using a Registry entry.
   # Although we don't want to delete the user's Lang Registry Setting
   # because he might have have selected a different language than his
@@ -74,13 +88,8 @@ Section "-gpg4win" SEC_gpg4win
   DeleteRegValue HKLM "Software\GNU\GnuPG" "gpgProgram"
   DetailPrint "Deleted obsolete gpgProgram value"
 
-  # Add the public directory to the PATH
-  Push "$INSTDIR\pub"
-  Call AddToPath
-  DetailPrint "Added pub directory to PATH"
-
   # Install gpg4win included tools
-  SetOutPath "$INSTDIR"
+  SetOutPath "$INSTDIR\bin"
   File "${BUILD_DIR}/sha1sum.exe"
   File "${BUILD_DIR}/sha256sum.exe"
   File "${BUILD_DIR}/md5sum.exe"