]> git.lyx.org Git - features.git/blobdiff - development/Win32/packaging/installer/setup/uninstall.nsh
Consider inset strings in simple find/replaceAll (#12049)
[features.git] / development / Win32 / packaging / installer / setup / uninstall.nsh
index ce1d49b02cbfb7e174a5d349175a56a2ae3a8da9..46419a86ba14c6fa44a1a6ee96fc1b210dac3905 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
 
 uninstall.nsh
 
@@ -25,14 +25,13 @@ Section "un.LyX" un.SecUnProgramFiles
   
   # Python
   RMDir /r "$INSTDIR\python"
+  ReadRegStr $0 SHCTX "Software\Classes\Python.File" "OnlyWithLyX" # test if it was registered by this LyX version
+  ${if} $0 == "Yes${APP_SERIES_KEY}"
+   DeleteRegKey SHCTX "Software\Classes\Python.File"
+  ${endif}
   
   # ImageMagick
   RMDir /r "$INSTDIR\imagemagick"
-  ReadRegStr $0 SHCTX "SOFTWARE\ImageMagick" "OnlyWithLyX" # test if it was installed together with this LyX version
-  ${if} $0 == "Yes${APP_SERIES_KEY}"
-   WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" ""
-   DeleteRegKey SHCTX "Software\ImageMagick"
-  ${endif}
   
   # Components of Ghostscript
   RMDir /r "$INSTDIR\ghostscript"
@@ -48,18 +47,18 @@ Section "un.LyX" un.SecUnProgramFiles
   ${if} $0 == "Yes${APP_SERIES_KEY}"
    ReadRegStr $R0 SHCTX "Software\Classes\${APP_EXT}" ""
    ${if} $R0 == "${APP_REGNAME_DOC}"
-    DeleteRegKey SHCTX "Software\Classes\${APP_EXT}13"
-    DeleteRegKey SHCTX "Software\Classes\${APP_EXT}14"
-    DeleteRegKey SHCTX "Software\Classes\${APP_EXT}15"
-    DeleteRegKey SHCTX "Software\Classes\${APP_EXT}16"
-   # enable this for LyX 2.1!
-   # DeleteRegKey SHCTX "Software\Classes\${APP_EXT}20"
+    #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}13"
+    #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}14"
+    #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}15"
+    #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}16"
+    #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}20"
+    #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}21"
     DeleteRegKey SHCTX "Software\Classes\${APP_EXT}"
-    DeleteRegKey SHCTX "Software\Classes\${APP_REGNAME_DOC}"
+    #DeleteRegKey SHCTX "Software\Classes\${APP_REGNAME_DOC}"
    ${endif}
   ${endif}
   ${if} $MultiUser.Privileges == "Admin"
-   DeleteRegKey HKCR "LyX.Document"
+   DeleteRegKey HKCR "${APP_NAME}.Document"
   ${endif}
 
   # Uninstaller itself
@@ -69,11 +68,29 @@ Section "un.LyX" un.SecUnProgramFiles
   SetOutPath "$TEMP"
   RMDir /r "$INSTDIR"
   
-  # Registry keys
+  # Registry keys and values
+  DeleteRegValue SHCTX "subkey" "key_name"
   DeleteRegKey SHCTX "${APP_REGKEY_SETUP}"
   DeleteRegKey SHCTX "${APP_REGKEY}"
   DeleteRegKey SHCTX "${APP_UNINST_KEY}"
-  DeleteRegKey HKCR "Applications\lyx.exe"
+  DeleteRegKey HKCR "Applications\${BIN_LYX}"
+  DeleteRegValue HKCR "${APP_NAME}.Document\Shell\open\command" ""
+  DeleteRegValue HKCR "${APP_NAME}.Document\DefaultIcon" ""
+  ReadRegStr $0 SHCTX ${APP_REGFOLDER} "latestVersion"
+  ${If} $0 == ${APP_SERIES_KEY}
+    DeleteRegValue SHCTX ${APP_REGFOLDER} "latestVersion"
+    StrCpy $0 0
+    StrCpy $R0 ""
+    ${Do}
+      StrCpy $R1 $R0
+      EnumRegKey $R0 SHCTX ${APP_REGFOLDER} $0
+      IntOp $0 $0 + 1
+    ${LoopUntil} $R0 == ""
+    ${If} $R1 != ""
+      WriteRegStr SHCTX ${APP_REGFOLDER} "latestVersion" $R1
+    ${EndIf}
+  ${EndIf}
+  DeleteRegKey /ifempty SHCTX ${APP_REGFOLDER}
   
   # File associations
   ReadRegStr $FileAssociation SHELL_CONTEXT "Software\Classes\${APP_EXT}" ""
@@ -82,19 +99,22 @@ Section "un.LyX" un.SecUnProgramFiles
      DeleteRegKey SHELL_CONTEXT "Software\Classes\${APP_EXT}"
   ${EndIf}
   
-  ${If} $MultiUser.Privileges == "Admin"
-  ${OrIf} $MultiUser.Privileges == "Power"
-   # Delete Postscript printer for metafile to EPS conversion
-   ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
-  ${EndIf}
-  
   # clean other registry entries
   DeleteRegKey SHCTX "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\${APP_NAME}.exe"
   DeleteRegKey SHCTX "SOFTWARE\${APP_REGKEY}"
   
   # delete info that programs were installed together with LyX
-  DeleteRegValue SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
-  DeleteRegValue SHCTX "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"  
+  DeleteRegValue SHCTX "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
+  
+  # for texindy the path to the perl.exe must unfortunately be in Windows' PATH variable
+  # so we have to remove it now
+  ${if} $MultiUser.Privileges != "Admin"
+  ${andif} $MultiUser.Privileges != "Power"
+   # call the non-admin version
+   ${un.EnvVarUpdate} $0 "PATH" "R" "HKCU" "$INSTDIR\Perl\bin"
+  ${else}
+   ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\Perl\bin"
+  ${endif}
 
 SectionEnd
 
@@ -105,12 +125,14 @@ Section /o "un.$(UnLyXPreferencesTitle)" un.SecUnPreferences
  # remove LyX's config files
  StrCpy $AppSubfolder ${APP_DIR_USERDATA}
  Call un.DelAppPathSub # function from LyXUtils.nsh
+ # remove registry settings
+ DeleteRegKey HKCU "Software\${APP_NAME}\${APP_NAME}${APP_SERIES_NAME}"
   
 SectionEnd
 
 #---------------------------------
 # MiKTeX
-Section /o "un.MiKTeX" un.SecUnMiKTeX
+Section "un.MiKTeX" un.SecUnMiKTeX
 
  ${if} $LaTeXInstalled == "MiKTeX" # only uninstall MiKTeX when it was installed together with LyX 
   ReadRegStr $1 SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\MiKTeX ${MiKTeXDeliveredVersion}" "UninstallString"
@@ -119,30 +141,10 @@ Section /o "un.MiKTeX" un.SecUnMiKTeX
 
 SectionEnd
 
-#---------------------------------
-# JabRef
-Section "un.JabRef" un.SecUnJabRef
-
- ${if} $JabRefInstalled == "Yes" # only uninstall JabRef when it was installed together with LyX
-  ${If} $MultiUser.Privileges == "Admin"
-  ${OrIf} $MultiUser.Privileges == "Power"
-   ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"
-   ExecWait "$1" # run JabRef's uninstaller
-  ${else}
-   # in this case we can only read the start menu location and then start the linked uninstaller
-   ReadRegStr $1 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "StartMenu"
-   StrCpy $1 "$1\Uninstall JabRef 2.8.lnk"
-   ExecShell "" "$1" # run JabRef's uninstaller
-  ${endif}
- ${endif}
-
-SectionEnd
-
 #---------------------------------
 # Section descriptions
 !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnMiKTeX} "$(SecUnMiKTeXDescription)"
-!insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnJabRef} "$(SecUnJabRefDescription)"
 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnPreferences} "$(SecUnPreferencesDescription)"
 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnProgramFiles} "$(SecUnProgramFilesDescription)"
 !insertmacro MUI_UNFUNCTION_DESCRIPTION_END