]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/installer/LyXWinInstaller/Uninstall.nsh
installer infrastructure changes according to Christian's comments
[lyx.git] / development / Win32 / packaging / installer / LyXWinInstaller / Uninstall.nsh
1 ; Uninstaller
2
3 ; this function is called at first after starting the uninstaller
4 Function un.onInit
5
6   ; Check that LyX is not currently running
7   FindProcDLL::FindProc "lyx.exe"
8   ${if} $R0 == "1"
9    MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
10    Abort
11   ${endif}
12
13   ; Ascertain whether the user has sufficient privileges to uninstall.
14   SetShellVarContext current
15
16   ReadRegStr $0 HKCU "${PRODUCT_UNINST_KEY}" "RootKey"
17   ${if} $0 == ""
18     ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "RootKey"
19     ${if} $0 == ""
20       MessageBox MB_OK|MB_ICONEXCLAMATION "$(UnNotInRegistryLabel)"
21     ${endif}
22   ${endif}
23
24   ; If the user does *not* have administrator privileges, abort
25   StrCpy $Answer ""
26   !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
27   ${if} $Answer == "yes"
28     SetShellVarContext all
29   ${else}
30     MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)"
31     Abort
32   ${endif}
33
34   ; Macro to investigate name of LyX's preferences folders to be able remove them
35   !insertmacro UnAppPreSuff $AppPre $AppSuff ; macro from LyXUtils.nsh
36
37   ; test if Aspell was installed together with LyX
38   ReadRegStr $0 HKLM "Software\Aspell" "OnlyWithLyX" ; special entry to test if it was installed with LyX
39   ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
40    SectionSetText 2 "Aspell" ; names the corersponding uninstaller section (has the index "2" as it is the third section in Uninstall.nsh)
41    StrCpy $AspellInstallYes "Aspell"
42   ${else}
43    SectionSetText 2 "" ; hides the corresponding uninstaller section
44   ${endif}
45
46   ; test if MiKTeX was installed together with LyX
47   ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
48   ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
49    SectionSetText 3 "MiKTeX" ; names the corersponding uninstaller section
50    StrCpy $MiKTeXInstalled "MiKTeX"
51   ${else}
52    SectionSetText 3 "" ; hides the corresponding uninstaller section
53   ${endif}
54
55   ; ignore JabRef because this could only be installed with the complete installer version
56    SectionSetText 4 "" ; hides the corresponding uninstaller section
57    StrCpy $JabRefInstalled ""
58
59   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2
60   Abort
61
62 FunctionEnd
63
64
65 Function un.onUninstSuccess
66   HideWindow
67   MessageBox MB_ICONINFORMATION|MB_OK "$(UnRemoveSuccessLabel)"
68   
69 FunctionEnd
70
71 ; Uninstall sections
72
73 Section "un.LyX" un.SecUnProgramFiles
74
75   SectionIn RO
76
77   ; delete LaTeX class files that were installed together with LyX
78   FileOpen $R5 "$INSTDIR\Resources\uninstallPaths.dat" r
79   FileRead $R5 $LatexPath
80   FileClose $R5
81   StrCpy $String $LatexPath
82   StrCpy $Search "miktex\bin"
83   StrLen $3 $String
84   Call un.StrPoint ; search the LaTeXPath for the phrase "miktex\bin" (function from LyXUtils.nsh)
85   ${if} $Pointer != "-1" ; if something was found
86    IntOp $Pointer $Pointer - 1 ; jump before the first "\" of "\miktex\bin"
87    StrCpy $String $String "$Pointer" ; $String is now the part before "\miktex\bin"
88    Delete "$String\tex\latex\cv.cls"
89    RMDir /r "$String\tex\latex\lyx"
90    RMDir /r "$String\tex\latex\revtex"
91    RMDir /r "$String\tex\latex\hollywood"
92    RMDir /r "$String\tex\latex\broadway"
93    ExecWait "$LatexPath\initexmf --update-fndb"
94   ${endif}
95
96   ; delete LyX's installation folder
97   RMDir /r $INSTDIR
98   ; delete start menu folder
99   ReadRegStr $0 ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "StartMenu"
100   RMDir /r "$0"
101   ; delete desktop icon
102   Delete "$DESKTOP\LyX ${PRODUCT_VERSION}.lnk"
103   ; delete registry entries
104   DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
105   DeleteRegKey ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
106   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
107   DeleteRegKey HKCR "Applications\lyx.exe"
108   DeleteRegKey HKCR "Applications\lyx.bat"
109
110   ; Aiksaurus
111   !insertmacro FileCheck $5 "meanings.dat" "${AiksaurusDir}" ; macro from LyXUtils.nsh
112   ${if} $5 == "True"
113    RMDir /r "${AiksaurusDir}"
114   ${endif}
115 ;  StrCpy $0 ""
116 ;  ReadRegStr $0 HKLM "Software\Aiksaurus" "OnlyWithLyX" ; special entry to test if it was installed with LyX
117 ;  ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}" 
118 ;   ; unregister Aiksaurus
119 ;   ReadRegStr $1 HKLM "Software\Aiksaurus" "Data Path"
120 ;   RMDir /r "$1"
121 ;   DeleteRegKey HKLM "SOFTWARE\Aiksaurus"
122 ;  ${endif}
123
124   ; ImageMagick
125   StrCpy $0 ""
126   ReadRegStr $0 HKLM "Software\ImageMagick" "OnlyWithLyX" ; special entry to test if it was installed with LyX
127   ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}" 
128    ; unregister ImageMagick
129    DeleteRegValue HKLM "SOFTWARE\Classes\Applications" "AutoRun"
130    DeleteRegKey HKLM "SOFTWARE\ImageMagick"
131   ${endif}
132   
133   ; Ghostscript and GSview
134   StrCpy $0 ""
135   StrCpy $5 ""
136   ReadRegStr $0 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" ; special entry to test if it was installed with LyX
137   ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
138    ; unregister Ghostscript
139    DeleteRegKey HKLM "SOFTWARE\GPL Ghostscript"
140    ; test if GSview is installed
141    EnumRegValue $5 HKLM "Software\Ghostgum\GSview" 0
142    ${if} $5 != ""
143     ; unregister GSview
144     MessageBox MB_ICONINFORMATION|MB_OK "$(UnGSview)"
145     ReadRegStr $3 HKLM "Software\Ghostgum\GSview" "$5"
146     ReadRegStr $4 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GSview $5" "UninstallString"
147     ExecWait "$4"
148    ${endif}
149   ${endif}
150   
151   ; MiKTeX specific LyX setting 
152   DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_AUTOINSTALL"
153   DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_REPOSITORY"
154   
155   ; remove extension .lyx
156   ${RemoveFileAssociation} "${PRODUCT_EXT}" "${PRODUCT_NAME}"
157   DeleteRegKey HKCR "${PRODUCT_NAME}"
158   
159   SetAutoClose true
160
161 SectionEnd
162
163 ;---------------------------------
164 ; user preferences
165 Section "un.$(UnLyXPreferencesTitle)" un.SecUnPreferences
166
167  ; remove LyX's config files
168  Call un.DelAppPathSub ; function from LyXUtils.nsh
169   
170 SectionEnd
171
172 ;---------------------------------
173 ; Aspell
174 Section "un.Aspell" un.SecUnAspell
175
176  ${if} $AspellInstallYes == "Aspell" ; only uninstall Aspell when it was installed together with LyX 
177   Call un.UninstAspell ; Function from Aspell.nsh
178  ${endif}
179
180 SectionEnd
181
182 ;---------------------------------
183 ; MiKTeX
184 Section "un.MiKTeX" un.SecUnMiKTeX
185
186  ${if} $MiKTeXInstalled == "MiKTeX" ; only uninstall MiKTeX when it was installed together with LyX 
187   ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${MiKTeXDeliveredVersion}" "UninstallString"
188   ExecWait "$1" ; run MiKTeX's uninstaller
189  ${endif}
190
191 SectionEnd
192
193 ;---------------------------------
194 ; JabRef
195 Section "un.JabRef" un.SecUnJabRef
196
197  ${if} $JabRefInstalled == "JabRef" ; only uninstall JabRef when it was installed together with LyX 
198   ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${JabRefVersion}" "UninstallString"
199   ExecWait "$1" ; run JabRef's uninstaller
200  ${endif}
201
202 SectionEnd
203
204 ;---------------------------------
205 ; Section descriptions
206 !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
207 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnAspell} "$(SecUnAspellDescription)"
208 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnMiKTeX} "$(SecUnMiKTeXDescription)"
209 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnJabRef} "$(SecUnJabRefDescription)"
210 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnPreferences} "$(SecUnPreferencesDescription)"
211 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnProgramFiles} "$(SecUnProgramFilesDescription)"
212 !insertmacro MUI_UNFUNCTION_DESCRIPTION_END
213