3 # this function is called at first after starting the uninstaller
6 # set the uninstaller language to the Windows locale language
7 System::Call "kernel32::GetUserDefaultLangID()i.a"
9 # Check that LyX is not currently running
10 FindProcDLL::FindProc "lyx.exe"
12 MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
16 # set registry root key
18 !insertmacro IsUserAdmin $Answer $UserName # macro from LyXUtils.nsh
19 ${if} $Answer == "yes"
20 SetShellVarContext all
22 SetShellVarContext current
25 # Ascertain whether the user has sufficient privileges to uninstall.
26 # abort when LyX was installed with admin permissions but the user doesn't have administrator privileges
27 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "RootKey"
29 ${andif} $Answer != "yes"
30 MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)"
33 # abort when LyX couldn't be found in the registry
34 ${if} $0 == "" # check in HKCU
35 ReadRegStr $0 HKCU "${PRODUCT_UNINST_KEY}" "RootKey"
37 MessageBox MB_OK|MB_ICONEXCLAMATION "$(UnNotInRegistryLabel)"
41 # printer settings, needed to uninstall the Metafile2eps printer
42 ${if} ${AtLeastWinVista}
43 StrCpy $PrinterConf "printui.exe"
45 StrCpy $PrinterConf "rundll32.exe printui.dll,PrintUIEntry"
48 # Macro to investigate name of LyX's preferences folders to be able remove them
49 !insertmacro UnAppPreSuff $AppPre $AppSuff # macro from LyXUtils.nsh
51 # test if Aspell was installed together with LyX
52 ReadRegStr $0 SHCTX "Software\Aspell" "OnlyWithLyX" # special entry to test if it was installed with LyX
53 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
54 SectionSetText 2 "Aspell" # names the corersponding uninstaller section (has the index "2" as it is the third section in Uninstall.nsh)
55 StrCpy $AspellInstallYes "Aspell"
56 DeleteRegValue SHCTX "Software\Aspell" "OnlyWithLyX" # special entry to test if it was installed with LyX
58 SectionSetText 2 "" # hides the corresponding uninstaller section
61 # test if MiKTeX was installed together with LyX
62 ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
63 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
64 SectionSetText 3 "MiKTeX" # names the corersponding uninstaller section
65 StrCpy $MiKTeXInstalled "MiKTeX"
66 DeleteRegValue HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
68 SectionSetText 3 "" # hides the corresponding uninstaller section
71 # test if JabRef was installed together with LyX
72 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
73 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
74 SectionSetText 4 "JabRef" # names the corersponding uninstaller section
75 StrCpy $JabRefInstalled "JabRef"
76 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
78 SectionSetText 4 "" # hides the corresponding uninstaller section
81 # question message if the user really wants to uninstall LyX
82 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2 # continue if yes
87 # ----------------------------------
89 Function un.onUninstSuccess
91 MessageBox MB_ICONINFORMATION|MB_OK "$(UnRemoveSuccessLabel)"
95 # ----------------------------------
98 Section "un.LyX" un.SecUnProgramFiles
102 # delete LaTeX class files that were installed together with LyX
103 FileOpen $R5 "$INSTDIR\Resources\uninstallPaths.dat" r
104 FileRead $R5 $LatexPath
106 StrCpy $String $LatexPath
107 StrCpy $Search "miktex\bin"
109 Call un.StrPoint # search the LaTeXPath for the phrase "miktex\bin" (function from LyXUtils.nsh)
110 ${if} $Pointer != "-1" # if something was found
111 IntOp $Pointer $Pointer - 1 # jump before the first "\" of "\miktex\bin"
112 StrCpy $String $String "$Pointer" # $String is now the part before "\miktex\bin"
113 Delete "$String\tex\latex\cv.cls"
114 RMDir /r "$String\tex\latex\lyx"
115 RMDir /r "$String\tex\latex\revtex"
116 RMDir /r "$String\tex\latex\hollywood"
117 RMDir /r "$String\tex\latex\broadway"
118 ExecWait "$LatexPath\initexmf --update-fndb"
121 # delete LyX's installation folder
123 # delete start menu folder
124 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
126 # delete desktop icon
127 Delete "$DESKTOP\LyX ${PRODUCT_VERSION}.lnk"
130 !insertmacro FileCheck $5 "meanings.dat" "${AiksaurusDir}" # macro from LyXUtils.nsh
132 RMDir /r "${AiksaurusDir}"
134 ReadRegStr $0 SHCTX "Software\Aiksaurus" "OnlyWithLyX" # special entry to test if it was installed with LyX
135 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
136 # unregister Aiksaurus
137 ReadRegStr $1 SHCTX "Software\Aiksaurus" "Data Path"
139 DeleteRegKey SHCTX "SOFTWARE\Aiksaurus"
142 # remove file extension .lyx
143 ReadRegStr $0 SHCTX "${PRODUCT_DIR_REGKEY}" "OnlyWithLyX" # special entry to test if they were registered by this LyX version
144 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
145 ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
146 ${if} $R0 == "${PRODUCT_REGNAME}"
147 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}13"
148 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}14"
149 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}15"
150 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}"
151 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_REGNAME}"
155 # delete registry entries
156 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
157 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
158 DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
159 DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY_2}"
160 DeleteRegKey HKCR "Applications\lyx.exe"
161 DeleteRegKey HKCR "Applications\lyx.bat"
163 # the following can only be done with admin permissions
164 ${if} $Answer == "yes" # if admin
167 ReadRegStr $0 SHCTX "Software\ImageMagick" "OnlyWithLyX" # special entry to test if it was installed with LyX
168 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
169 # unregister ImageMagick
170 DeleteRegValue SHCTX "SOFTWARE\Classes\Applications" "AutoRun"
171 DeleteRegKey SHCTX "SOFTWARE\ImageMagick"
175 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Metafile to EPS Converter" "OnlyWithLyX" # special entry to test if it was installed with LyX
176 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
178 ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
179 # unregister Metafile2eps
180 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Metafile to EPS Converter"
181 DeleteRegKey HKLM "Software\InkNote Selector"
184 # Ghostscript and GSview
185 ReadRegStr $0 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" # special entry to test if it was installed with LyX
186 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
187 # unregister Ghostscript
188 DeleteRegKey HKLM "SOFTWARE\GPL Ghostscript"
189 # test if GSview is installed
191 EnumRegValue $5 HKLM "Software\Ghostgum\GSview" 0
194 MessageBox MB_ICONINFORMATION|MB_OK "$(UnGSview)"
195 ReadRegStr $3 HKLM "Software\Ghostgum\GSview" "$5"
196 ReadRegStr $4 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GSview $5" "UninstallString"
201 # MiKTeX specific LyX setting !Can be deleted after LyX 1.5.0beta3!
202 DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_AUTOINSTALL"
203 DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_REPOSITORY"
205 ${endif} # end if Answer (if admin)
211 #---------------------------------
213 Section "un.$(UnLyXPreferencesTitle)" un.SecUnPreferences
215 # remove LyX's config files
216 StrCpy $AppSubfolder ${PRODUCT_SUBFOLDER}
217 Call un.DelAppPathSub # function from LyXUtils.nsh
221 #---------------------------------
223 Section "un.Aspell" un.SecUnAspell
225 ${if} $AspellInstallYes == "Aspell" # only uninstall Aspell when it was installed together with LyX
226 Call un.UninstAspell # Function from Aspell.nsh
231 #---------------------------------
233 Section "un.MiKTeX" un.SecUnMiKTeX
235 ${if} $MiKTeXInstalled == "MiKTeX" # only uninstall MiKTeX when it was installed together with LyX
236 ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MiKTeX ${MiKTeXDeliveredVersion}" "UninstallString"
237 ExecWait $1 # run MiKTeX's uninstaller
242 #---------------------------------
244 Section "un.JabRef" un.SecUnJabRef
246 ${if} $JabRefInstalled == "JabRef" # only uninstall JabRef when it was installed together with LyX
247 ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"
248 ExecWait "$1" # run JabRef's uninstaller
253 #---------------------------------
254 # Section descriptions
255 !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
256 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnAspell} "$(SecUnAspellDescription)"
257 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnMiKTeX} "$(SecUnMiKTeXDescription)"
258 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnJabRef} "$(SecUnJabRefDescription)"
259 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnPreferences} "$(SecUnPreferencesDescription)"
260 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnProgramFiles} "$(SecUnProgramFilesDescription)"
261 !insertmacro MUI_UNFUNCTION_DESCRIPTION_END