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"
47 SectionSetText 2 "" # hides the corresponding uninstaller section
50 # test if MiKTeX was installed together with LyX
51 ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
52 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
53 SectionSetText 3 "MiKTeX" # names the corersponding uninstaller section
54 StrCpy $MiKTeXInstalled "MiKTeX"
56 SectionSetText 3 "" # hides the corresponding uninstaller section
59 # test if JabRef was installed together with LyX
60 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$JabRefVersionVar" "OnlyWithLyX"
61 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
62 SectionSetText 4 "JabRef" # names the corersponding uninstaller section
63 StrCpy $JabRefInstalled "JabRef"
65 SectionSetText 4 "" # hides the corresponding uninstaller section
68 # question message if the user really wants to uninstall LyX
69 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2 # continue if yes
74 # ----------------------------------
76 Function un.onUninstSuccess
78 MessageBox MB_ICONINFORMATION|MB_OK "$(UnRemoveSuccessLabel)"
82 # ----------------------------------
85 Section "un.LyX" un.SecUnProgramFiles
89 # delete LaTeX class files that were installed together with LyX
90 FileOpen $R5 "$INSTDIR\Resources\uninstallPaths.dat" r
91 FileRead $R5 $LatexPath
93 StrCpy $String $LatexPath
94 StrCpy $Search "miktex\bin"
96 Call un.StrPoint # search the LaTeXPath for the phrase "miktex\bin" (function from LyXUtils.nsh)
97 ${if} $Pointer != "-1" # if something was found
98 IntOp $Pointer $Pointer - 1 # jump before the first "\" of "\miktex\bin"
99 StrCpy $String $String "$Pointer" # $String is now the part before "\miktex\bin"
100 Delete "$String\tex\latex\cv.cls"
101 RMDir /r "$String\tex\latex\lyx"
102 RMDir /r "$String\tex\latex\revtex"
103 RMDir /r "$String\tex\latex\hollywood"
104 RMDir /r "$String\tex\latex\broadway"
105 ExecWait "$LatexPath\initexmf --update-fndb"
108 # delete LyX's installation folder
110 # delete start menu folder
111 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
113 # delete desktop icon
114 Delete "$DESKTOP\LyX ${PRODUCT_VERSION}.lnk"
115 # delete registry entries
116 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
117 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
118 DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
119 DeleteRegKey HKCR "Applications\lyx.exe"
120 DeleteRegKey HKCR "Applications\lyx.bat"
123 !insertmacro FileCheck $5 "meanings.dat" "${AiksaurusDir}" # macro from LyXUtils.nsh
125 RMDir /r "${AiksaurusDir}"
127 ReadRegStr $0 SHCTX "Software\Aiksaurus" "OnlyWithLyX" # special entry to test if it was installed with LyX
128 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
129 # unregister Aiksaurus
130 ReadRegStr $1 SHCTX "Software\Aiksaurus" "Data Path"
132 DeleteRegKey SHCTX "SOFTWARE\Aiksaurus"
135 # remove file extension .lyx
136 ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
137 ${if} $R0 == "${PRODUCT_REGNAME}"
138 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}"
139 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_REGNAME}"
142 # the following can only be done with admin permissions
143 ${if} $Answer == "yes" # if admin
146 ReadRegStr $0 SHCTX "Software\ImageMagick" "OnlyWithLyX" # special entry to test if it was installed with LyX
147 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
148 # unregister ImageMagick
149 DeleteRegValue SHCTX "SOFTWARE\Classes\Applications" "AutoRun"
150 DeleteRegKey SHCTX "SOFTWARE\ImageMagick"
153 # Ghostscript and GSview
154 ReadRegStr $0 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" # special entry to test if it was installed with LyX
155 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
156 # unregister Ghostscript
157 DeleteRegKey HKLM "SOFTWARE\GPL Ghostscript"
158 # test if GSview is installed
160 EnumRegValue $5 HKLM "Software\Ghostgum\GSview" 0
163 MessageBox MB_ICONINFORMATION|MB_OK "$(UnGSview)"
164 ReadRegStr $3 HKLM "Software\Ghostgum\GSview" "$5"
165 ReadRegStr $4 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GSview $5" "UninstallString"
170 # MiKTeX specific LyX setting
171 DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_AUTOINSTALL"
172 DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_REPOSITORY"
174 ${endif} # end if Answer (if admin)
180 #---------------------------------
182 Section "un.$(UnLyXPreferencesTitle)" un.SecUnPreferences
184 # remove LyX's config files
185 Call un.DelAppPathSub # function from LyXUtils.nsh
189 #---------------------------------
191 Section "un.Aspell" un.SecUnAspell
193 ${if} $AspellInstallYes == "Aspell" # only uninstall Aspell when it was installed together with LyX
194 Call un.UninstAspell # Function from Aspell.nsh
199 #---------------------------------
201 Section "un.MiKTeX" un.SecUnMiKTeX
203 ${if} $MiKTeXInstalled == "MiKTeX" # only uninstall MiKTeX when it was installed together with LyX
204 ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$MiKTeXVersionVar" "UninstallString"
205 ExecWait "$1" # run MiKTeX's uninstaller
210 #---------------------------------
212 Section "un.JabRef" un.SecUnJabRef
214 ${if} $JabRefInstalled == "JabRef" # only uninstall JabRef when it was installed together with LyX
215 ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$JabRefVersionVar" "UninstallString"
216 ExecWait "$1" # run JabRef's uninstaller
221 #---------------------------------
222 # Section descriptions
223 !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
224 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnAspell} "$(SecUnAspellDescription)"
225 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnMiKTeX} "$(SecUnMiKTeXDescription)"
226 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnJabRef} "$(SecUnJabRefDescription)"
227 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnPreferences} "$(SecUnPreferencesDescription)"
228 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnProgramFiles} "$(SecUnProgramFilesDescription)"
229 !insertmacro MUI_UNFUNCTION_DESCRIPTION_END