3 # this function is called at first after starting the uninstaller
6 # Check that LyX is not currently running
7 FindProcDLL::FindProc "lyx.exe"
9 MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
13 # set registry root key
15 !insertmacro IsUserAdmin $Answer $UserName # macro from LyXUtils.nsh
16 ${if} $Answer == "yes"
17 SetShellVarContext all
19 SetShellVarContext current
22 # Ascertain whether the user has sufficient privileges to uninstall.
23 # abort when LyX was installed with admin permissions but the user doesn't have administrator privileges
24 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "RootKey"
26 ${andif} $Answer != "yes"
27 MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)"
30 # abort when LyX couldn't be found in the registry
31 ${if} $0 == "" # check in HKCU
32 ReadRegStr $0 HKCU "${PRODUCT_UNINST_KEY}" "RootKey"
34 MessageBox MB_OK|MB_ICONEXCLAMATION "$(UnNotInRegistryLabel)"
38 # Macro to investigate name of LyX's preferences folders to be able remove them
39 !insertmacro UnAppPreSuff $AppPre $AppSuff # macro from LyXUtils.nsh
41 # test if Aspell was installed together with LyX
42 ReadRegStr $0 SHCTX "Software\Aspell" "OnlyWithLyX" # special entry to test if it was installed with LyX
43 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
44 SectionSetText 2 "Aspell" # names the corersponding uninstaller section (has the index "2" as it is the third section in Uninstall.nsh)
45 StrCpy $AspellInstallYes "Aspell"
46 DeleteRegValue SHCTX "Software\Aspell" "OnlyWithLyX" # special entry to test if it was installed with LyX
48 SectionSetText 2 "" # hides the corresponding uninstaller section
51 # test if MiKTeX was installed together with LyX
52 ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
53 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
54 SectionSetText 3 "MiKTeX" # names the corersponding uninstaller section
55 StrCpy $MiKTeXInstalled "MiKTeX"
56 DeleteRegValue HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
58 SectionSetText 3 "" # hides the corresponding uninstaller section
61 # test if JabRef was installed together with LyX
62 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
63 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
64 SectionSetText 4 "JabRef" # names the corersponding uninstaller section
65 StrCpy $JabRefInstalled "JabRef"
66 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
68 SectionSetText 4 "" # hides the corresponding uninstaller section
71 # question message if the user really wants to uninstall LyX
72 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2 # continue if yes
77 # ----------------------------------
79 Function un.onUninstSuccess
81 MessageBox MB_ICONINFORMATION|MB_OK "$(UnRemoveSuccessLabel)"
85 # ----------------------------------
88 Section "un.LyX" un.SecUnProgramFiles
92 # delete LaTeX class files that were installed together with LyX
93 FileOpen $R5 "$INSTDIR\Resources\uninstallPaths.dat" r
94 FileRead $R5 $LatexPath
96 StrCpy $String $LatexPath
97 StrCpy $Search "miktex\bin"
99 Call un.StrPoint # search the LaTeXPath for the phrase "miktex\bin" (function from LyXUtils.nsh)
100 ${if} $Pointer != "-1" # if something was found
101 IntOp $Pointer $Pointer - 1 # jump before the first "\" of "\miktex\bin"
102 StrCpy $String $String "$Pointer" # $String is now the part before "\miktex\bin"
103 Delete "$String\tex\latex\cv.cls"
104 RMDir /r "$String\tex\latex\lyx"
105 RMDir /r "$String\tex\latex\revtex"
106 RMDir /r "$String\tex\latex\hollywood"
107 RMDir /r "$String\tex\latex\broadway"
108 ExecWait "$LatexPath\initexmf --update-fndb"
111 # delete LyX's installation folder
113 # delete start menu folder
114 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
116 # delete desktop icon
117 Delete "$DESKTOP\LyX ${PRODUCT_VERSION}.lnk"
118 # delete registry entries
119 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
120 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
121 DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
122 DeleteRegKey HKCR "Applications\lyx.exe"
123 DeleteRegKey HKCR "Applications\lyx.bat"
126 !insertmacro FileCheck $5 "meanings.dat" "${AiksaurusDir}" # macro from LyXUtils.nsh
128 RMDir /r "${AiksaurusDir}"
130 ReadRegStr $0 SHCTX "Software\Aiksaurus" "OnlyWithLyX" # special entry to test if it was installed with LyX
131 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
132 # unregister Aiksaurus
133 ReadRegStr $1 SHCTX "Software\Aiksaurus" "Data Path"
135 DeleteRegKey SHCTX "SOFTWARE\Aiksaurus"
138 # remove file extension .lyx
139 ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
140 ${if} $R0 == "${PRODUCT_REGNAME}"
141 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}"
142 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_REGNAME}"
145 # the following can only be done with admin permissions
146 ${if} $Answer == "yes" # if admin
149 ReadRegStr $0 SHCTX "Software\ImageMagick" "OnlyWithLyX" # special entry to test if it was installed with LyX
150 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
151 # unregister ImageMagick
152 DeleteRegValue SHCTX "SOFTWARE\Classes\Applications" "AutoRun"
153 DeleteRegKey SHCTX "SOFTWARE\ImageMagick"
156 # Ghostscript and GSview
157 ReadRegStr $0 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" # special entry to test if it was installed with LyX
158 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
159 # unregister Ghostscript
160 DeleteRegKey HKLM "SOFTWARE\GPL Ghostscript"
161 # test if GSview is installed
163 EnumRegValue $5 HKLM "Software\Ghostgum\GSview" 0
166 MessageBox MB_ICONINFORMATION|MB_OK "$(UnGSview)"
167 ReadRegStr $3 HKLM "Software\Ghostgum\GSview" "$5"
168 ReadRegStr $4 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GSview $5" "UninstallString"
173 # MiKTeX specific LyX setting !Can be deleted after LyX 1.5.0beta3!
174 DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_AUTOINSTALL"
175 DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_REPOSITORY"
177 ${endif} # end if Answer (if admin)
183 #---------------------------------
185 Section "un.$(UnLyXPreferencesTitle)" un.SecUnPreferences
187 # remove LyX's config files
188 Call un.DelAppPathSub # function from LyXUtils.nsh
192 #---------------------------------
194 Section "un.Aspell" un.SecUnAspell
196 ${if} $AspellInstallYes == "Aspell" # only uninstall Aspell when it was installed together with LyX
197 Call un.UninstAspell # Function from Aspell.nsh
202 #---------------------------------
204 Section "un.MiKTeX" un.SecUnMiKTeX
206 ${if} $MiKTeXInstalled == "MiKTeX" # only uninstall MiKTeX when it was installed together with LyX
207 ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MiKTeX ${MiKTeXDeliveredVersion}" "UninstallString"
208 ExecWait $1 # run MiKTeX's uninstaller
213 #---------------------------------
215 Section "un.JabRef" un.SecUnJabRef
217 ${if} $JabRefInstalled == "JabRef" # only uninstall JabRef when it was installed together with LyX
218 ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"
219 ExecWait "$1" # run JabRef's uninstaller
224 #---------------------------------
225 # Section descriptions
226 !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
227 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnAspell} "$(SecUnAspellDescription)"
228 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnMiKTeX} "$(SecUnMiKTeXDescription)"
229 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnJabRef} "$(SecUnJabRefDescription)"
230 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnPreferences} "$(SecUnPreferencesDescription)"
231 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnProgramFiles} "$(SecUnProgramFilesDescription)"
232 !insertmacro MUI_UNFUNCTION_DESCRIPTION_END