2007-05-01 17:55:54 +00:00
# Uninstaller
2007-04-16 22:33:53 +00:00
2007-05-01 17:55:54 +00:00
# this function is called at first after starting the uninstaller
2007-04-16 22:33:53 +00:00
Function un.onInit
2007-05-01 17:55:54 +00:00
# Check that LyX is not currently running
2007-04-16 22:33:53 +00:00
FindProcDLL::FindProc "lyx.exe"
${if} $R0 == "1"
MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
Abort
${endif}
2007-05-01 17:55:54 +00:00
# set registry root key
2007-04-16 22:33:53 +00:00
StrCpy $Answer ""
2007-05-01 17:55:54 +00:00
!insertmacro IsUserAdmin $Answer $UserName # macro from LyXUtils.nsh
2007-04-16 22:33:53 +00:00
${if} $Answer == "yes"
SetShellVarContext all
${else}
2007-04-19 00:55:52 +00:00
SetShellVarContext current
${endif}
2007-05-01 17:55:54 +00:00
# Ascertain whether the user has sufficient privileges to uninstall.
# abort when LyX was installed with admin permissions but the user doesn't have administrator privileges
2007-04-19 00:55:52 +00:00
ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "RootKey"
${if} $0 != ""
${andif} $Answer != "yes"
MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)"
Abort
${endif}
2007-05-01 17:55:54 +00:00
# abort when LyX couldn't be found in the registry
${if} $0 == "" # check in HKCU
2007-04-19 00:55:52 +00:00
ReadRegStr $0 HKCU "${PRODUCT_UNINST_KEY}" "RootKey"
${if} $0 == ""
MessageBox MB_OK|MB_ICONEXCLAMATION "$(UnNotInRegistryLabel)"
${endif}
2007-04-16 22:33:53 +00:00
${endif}
2008-11-12 02:32:02 +00:00
# printer settings, needed to uninstall the Metafile2eps printer
2008-12-15 00:58:50 +00:00
${if} ${AtLeastWinVista}
StrCpy $PrinterConf "printui.exe"
${else}
StrCpy $PrinterConf "rundll32.exe printui.dll,PrintUIEntry"
${endif}
2007-04-16 22:33:53 +00:00
2007-05-01 17:55:54 +00:00
# Macro to investigate name of LyX's preferences folders to be able remove them
!insertmacro UnAppPreSuff $AppPre $AppSuff # macro from LyXUtils.nsh
2007-04-16 22:33:53 +00:00
2007-05-01 17:55:54 +00:00
# test if Aspell was installed together with LyX
ReadRegStr $0 SHCTX "Software\Aspell" "OnlyWithLyX" # special entry to test if it was installed with LyX
2007-04-16 22:33:53 +00:00
${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
2007-05-01 17:55:54 +00:00
SectionSetText 2 "Aspell" # names the corersponding uninstaller section (has the index "2" as it is the third section in Uninstall.nsh)
2007-04-16 22:33:53 +00:00
StrCpy $AspellInstallYes "Aspell"
2007-05-15 01:31:19 +00:00
DeleteRegValue SHCTX "Software\Aspell" "OnlyWithLyX" # special entry to test if it was installed with LyX
2007-04-16 22:33:53 +00:00
${else}
2007-05-01 17:55:54 +00:00
SectionSetText 2 "" # hides the corresponding uninstaller section
2007-04-16 22:33:53 +00:00
${endif}
2007-05-01 17:55:54 +00:00
# test if MiKTeX was installed together with LyX
2007-04-16 22:33:53 +00:00
ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
2007-05-01 17:55:54 +00:00
SectionSetText 3 "MiKTeX" # names the corersponding uninstaller section
2007-04-16 22:33:53 +00:00
StrCpy $MiKTeXInstalled "MiKTeX"
2007-05-15 01:31:19 +00:00
DeleteRegValue HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
2007-04-16 22:33:53 +00:00
${else}
2007-05-01 17:55:54 +00:00
SectionSetText 3 "" # hides the corresponding uninstaller section
2007-04-16 22:33:53 +00:00
${endif}
2007-05-01 17:55:54 +00:00
# test if JabRef was installed together with LyX
2007-05-15 01:31:19 +00:00
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
2007-04-19 00:55:52 +00:00
${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
2007-05-01 17:55:54 +00:00
SectionSetText 4 "JabRef" # names the corersponding uninstaller section
2007-04-19 00:55:52 +00:00
StrCpy $JabRefInstalled "JabRef"
2007-05-15 01:31:19 +00:00
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
2007-04-19 00:55:52 +00:00
${else}
2007-05-01 17:55:54 +00:00
SectionSetText 4 "" # hides the corresponding uninstaller section
2007-04-19 00:55:52 +00:00
${endif}
2007-04-16 22:33:53 +00:00
2007-05-01 17:55:54 +00:00
# question message if the user really wants to uninstall LyX
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2 # continue if yes
2007-04-16 22:33:53 +00:00
Abort
FunctionEnd
2007-05-01 17:55:54 +00:00
# ----------------------------------
2007-04-16 22:33:53 +00:00
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(UnRemoveSuccessLabel)"
FunctionEnd
2007-05-01 17:55:54 +00:00
# ----------------------------------
# Uninstall sections
2007-02-08 21:09:30 +00:00
Section "un.LyX" un.SecUnProgramFiles
SectionIn RO
2007-05-01 17:55:54 +00:00
# delete LaTeX class files that were installed together with LyX
2007-02-08 21:09:30 +00:00
FileOpen $R5 "$INSTDIR\Resources\uninstallPaths.dat" r
FileRead $R5 $LatexPath
FileClose $R5
StrCpy $String $LatexPath
StrCpy $Search "miktex\bin"
StrLen $3 $String
2007-05-01 17:55:54 +00:00
Call un.StrPoint # search the LaTeXPath for the phrase "miktex\bin" (function from LyXUtils.nsh)
${if} $Pointer != "-1" # if something was found
IntOp $Pointer $Pointer - 1 # jump before the first "\" of "\miktex\bin"
StrCpy $String $String "$Pointer" # $String is now the part before "\miktex\bin"
2007-02-08 21:09:30 +00:00
Delete "$String\tex\latex\cv.cls"
RMDir /r "$String\tex\latex\lyx"
RMDir /r "$String\tex\latex\revtex"
RMDir /r "$String\tex\latex\hollywood"
RMDir /r "$String\tex\latex\broadway"
ExecWait "$LatexPath\initexmf --update-fndb"
${endif}
2007-05-01 17:55:54 +00:00
# delete LyX's installation folder
2007-02-08 21:09:30 +00:00
RMDir /r $INSTDIR
2007-05-01 17:55:54 +00:00
# delete start menu folder
2007-04-19 00:55:52 +00:00
ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
2007-02-08 21:09:30 +00:00
RMDir /r "$0"
2007-05-01 17:55:54 +00:00
# delete desktop icon
2007-04-15 22:03:42 +00:00
Delete "$DESKTOP\LyX ${PRODUCT_VERSION}.lnk"
2008-04-24 01:34:33 +00:00
2007-05-01 17:55:54 +00:00
# Aiksaurus
!insertmacro FileCheck $5 "meanings.dat" "${AiksaurusDir}" # macro from LyXUtils.nsh
2007-02-08 21:09:30 +00:00
${if} $5 == "True"
RMDir /r "${AiksaurusDir}"
${endif}
2007-05-01 17:55:54 +00:00
ReadRegStr $0 SHCTX "Software\Aiksaurus" "OnlyWithLyX" # special entry to test if it was installed with LyX
2007-04-12 20:18:08 +00:00
${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
2007-05-01 17:55:54 +00:00
# unregister Aiksaurus
2007-04-19 00:55:52 +00:00
ReadRegStr $1 SHCTX "Software\Aiksaurus" "Data Path"
RMDir /r "$1"
DeleteRegKey SHCTX "SOFTWARE\Aiksaurus"
2007-02-08 21:09:30 +00:00
${endif}
2007-04-19 00:55:52 +00:00
2007-05-01 17:55:54 +00:00
# remove file extension .lyx
2008-04-23 01:33:21 +00:00
ReadRegStr $0 SHCTX "${PRODUCT_DIR_REGKEY}" "OnlyWithLyX" # special entry to test if they were registered by this LyX version
${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
${if} $R0 == "${PRODUCT_REGNAME}"
2008-11-15 15:04:49 +00:00
DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}13"
DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}14"
DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}15"
2008-04-23 01:33:21 +00:00
DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}"
DeleteRegKey SHCTX "Software\Classes\${PRODUCT_REGNAME}"
${endif}
2007-05-01 14:21:21 +00:00
${endif}
2008-04-24 01:34:33 +00:00
# delete registry entries
DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY_2}"
DeleteRegKey HKCR "Applications\lyx.exe"
DeleteRegKey HKCR "Applications\lyx.bat"
2007-05-01 14:21:21 +00:00
2007-05-01 17:55:54 +00:00
# the following can only be done with admin permissions
${if} $Answer == "yes" # if admin
2007-02-08 21:09:30 +00:00
2007-05-01 17:55:54 +00:00
# ImageMagick
ReadRegStr $0 SHCTX "Software\ImageMagick" "OnlyWithLyX" # special entry to test if it was installed with LyX
2007-04-19 00:55:52 +00:00
${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
2007-05-01 17:55:54 +00:00
# unregister ImageMagick
2007-04-19 00:55:52 +00:00
DeleteRegValue SHCTX "SOFTWARE\Classes\Applications" "AutoRun"
DeleteRegKey SHCTX "SOFTWARE\ImageMagick"
${endif}
2008-11-12 02:32:02 +00:00
# Metafile2eps
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Metafile to EPS Converter" "OnlyWithLyX" # special entry to test if it was installed with LyX
${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
# Delete printer
ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
# unregister Metafile2eps
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Metafile to EPS Converter"
DeleteRegKey HKLM "Software\InkNote Selector"
${endif}
2007-02-08 21:09:30 +00:00
2007-05-01 17:55:54 +00:00
# Ghostscript and GSview
ReadRegStr $0 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" # special entry to test if it was installed with LyX
2007-04-19 00:55:52 +00:00
${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
2007-05-01 17:55:54 +00:00
# unregister Ghostscript
2007-04-19 00:55:52 +00:00
DeleteRegKey HKLM "SOFTWARE\GPL Ghostscript"
2007-05-01 17:55:54 +00:00
# test if GSview is installed
2007-04-19 00:55:52 +00:00
StrCpy $5 ""
EnumRegValue $5 HKLM "Software\Ghostgum\GSview" 0
${if} $5 != ""
2007-05-01 17:55:54 +00:00
# unregister GSview
2007-04-19 00:55:52 +00:00
MessageBox MB_ICONINFORMATION|MB_OK "$(UnGSview)"
ReadRegStr $3 HKLM "Software\Ghostgum\GSview" "$5"
ReadRegStr $4 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GSview $5" "UninstallString"
ExecWait "$4"
${endif}
${endif}
2007-05-15 01:31:19 +00:00
# MiKTeX specific LyX setting !Can be deleted after LyX 1.5.0beta3!
2007-04-19 00:55:52 +00:00
DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_AUTOINSTALL"
DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_REPOSITORY"
2007-05-01 17:55:54 +00:00
${endif} # end if Answer (if admin)
2007-02-08 21:09:30 +00:00
SetAutoClose true
SectionEnd
2007-05-01 17:55:54 +00:00
#---------------------------------
# user preferences
2007-02-08 21:09:30 +00:00
Section "un.$(UnLyXPreferencesTitle)" un.SecUnPreferences
2007-05-01 17:55:54 +00:00
# remove LyX's config files
2008-06-04 01:26:56 +00:00
StrCpy $AppSubfolder ${PRODUCT_SUBFOLDER}
2007-05-01 17:55:54 +00:00
Call un.DelAppPathSub # function from LyXUtils.nsh
2007-02-08 21:09:30 +00:00
SectionEnd
2007-05-01 17:55:54 +00:00
#---------------------------------
# Aspell
2007-02-08 21:09:30 +00:00
Section "un.Aspell" un.SecUnAspell
2007-05-01 17:55:54 +00:00
${if} $AspellInstallYes == "Aspell" # only uninstall Aspell when it was installed together with LyX
Call un.UninstAspell # Function from Aspell.nsh
2007-02-08 21:09:30 +00:00
${endif}
SectionEnd
2007-05-01 17:55:54 +00:00
#---------------------------------
# MiKTeX
2007-02-08 21:09:30 +00:00
Section "un.MiKTeX" un.SecUnMiKTeX
2007-05-01 17:55:54 +00:00
${if} $MiKTeXInstalled == "MiKTeX" # only uninstall MiKTeX when it was installed together with LyX
2007-05-15 01:31:19 +00:00
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MiKTeX ${MiKTeXDeliveredVersion}" "UninstallString"
ExecWait $1 # run MiKTeX's uninstaller
2007-02-08 21:09:30 +00:00
${endif}
SectionEnd
2007-05-01 17:55:54 +00:00
#---------------------------------
# JabRef
2007-02-08 21:09:30 +00:00
Section "un.JabRef" un.SecUnJabRef
2007-05-01 17:55:54 +00:00
${if} $JabRefInstalled == "JabRef" # only uninstall JabRef when it was installed together with LyX
2007-05-15 01:31:19 +00:00
ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"
2007-05-01 17:55:54 +00:00
ExecWait "$1" # run JabRef's uninstaller
2007-02-08 21:09:30 +00:00
${endif}
SectionEnd
2007-05-01 17:55:54 +00:00
#---------------------------------
# Section descriptions
2007-02-08 21:09:30 +00:00
!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnAspell} "$(SecUnAspellDescription)"
!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