]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/uninstall.nsh
Win installer: fix a bug
[features.git] / development / Win32 / packaging / installer / setup / uninstall.nsh
1 /*
2
3 uninstall.nsh
4
5 Uninstall 
6
7 */
8
9 Var FileAssociation
10
11 # ----------------------------------
12
13 Section "un.LyX" un.SecUnProgramFiles
14
15   SectionIn RO
16   # LaTeX class files that were installed together with LyX
17   # will not be uninstalled because other LyX versions will
18   # need them and these few files don't harm to stay in LaTeX 
19     
20   # Binaries
21   RMDir /r "$INSTDIR\bin"
22
23   # Resources
24   RMDir /r "$INSTDIR\Resources"
25   
26   # Python
27   RMDir /r "$INSTDIR\python"
28   ReadRegStr $0 SHCTX "Software\Classes\Python.File" "OnlyWithLyX" # test if it was registered by this LyX version
29   ${if} $0 == "Yes${APP_SERIES_KEY}"
30    DeleteRegKey SHCTX "Software\Classes\Python.File"
31   ${endif}
32   
33   # ImageMagick
34   RMDir /r "$INSTDIR\imagemagick"
35   ReadRegStr $0 SHCTX "SOFTWARE\ImageMagick" "OnlyWithLyX" # test if it was installed together with this LyX version
36   ${if} $0 == "Yes${APP_SERIES_KEY}"
37    WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" ""
38    DeleteRegKey SHCTX "Software\ImageMagick"
39   ${endif}
40   
41   # Components of Ghostscript
42   RMDir /r "$INSTDIR\ghostscript"
43   
44   # delete start menu folder
45   ReadRegStr $0 SHCTX "${APP_UNINST_KEY}" "StartMenu"
46   RMDir /r "$0"
47   # delete desktop icon
48   Delete "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
49   
50   # remove file extension .lyx
51   ReadRegStr $0 SHCTX "${APP_DIR_REGKEY}" "OnlyWithLyX" # test if they were registered by this LyX version
52   ${if} $0 == "Yes${APP_SERIES_KEY}"
53    ReadRegStr $R0 SHCTX "Software\Classes\${APP_EXT}" ""
54    ${if} $R0 == "${APP_REGNAME_DOC}"
55     #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}13"
56     #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}14"
57     #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}15"
58     #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}16"
59     #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}20"
60     #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}21"
61     DeleteRegKey SHCTX "Software\Classes\${APP_EXT}"
62     #DeleteRegKey SHCTX "Software\Classes\${APP_REGNAME_DOC}"
63    ${endif}
64   ${endif}
65   ${if} $MultiUser.Privileges == "Admin"
66    DeleteRegKey HKCR "LyX.Document"
67   ${endif}
68
69   # Uninstaller itself
70   Delete "$INSTDIR\${SETUP_UNINSTALLER}"
71   
72   # Application folder
73   SetOutPath "$TEMP"
74   RMDir /r "$INSTDIR"
75   
76   # Registry keys and values
77   DeleteRegKey SHCTX "${APP_REGKEY_SETUP}"
78   DeleteRegKey SHCTX "${APP_REGKEY}"
79   DeleteRegKey SHCTX "${APP_UNINST_KEY}"
80   DeleteRegKey HKCR "Applications\lyx.exe"
81   DeleteRegValue HKCR "LyX.Document\Shell\open\command" ""
82   DeleteRegValue HKCR "LyX.Document\DefaultIcon" ""
83   
84   # File associations
85   ReadRegStr $FileAssociation SHELL_CONTEXT "Software\Classes\${APP_EXT}" ""
86   
87   ${If} $FileAssociation == "${APP_REGNAME_DOC}"
88      DeleteRegKey SHELL_CONTEXT "Software\Classes\${APP_EXT}"
89   ${EndIf}
90   
91   # clean other registry entries
92   DeleteRegKey SHCTX "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\${APP_NAME}.exe"
93   DeleteRegKey SHCTX "SOFTWARE\${APP_REGKEY}"
94   
95   # delete info that programs were installed together with LyX
96   DeleteRegValue SHCTX "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
97   DeleteRegValue SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef" "OnlyWithLyX"
98   
99   # for texindy the path to the perl.exe must unfortunately be in Windows' PATH variable
100   # so we have to remove it now
101   ${if} $MultiUser.Privileges != "Admin"
102   ${andif} $MultiUser.Privileges != "Power"
103    # call the non-admin version
104    ${un.EnvVarUpdate} $0 "PATH" "R" "HKCU" "$INSTDIR\Perl\bin"
105   ${else}
106    ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\Perl\bin"
107   ${endif}
108
109 SectionEnd
110
111 #---------------------------------
112 # user preferences
113 Section /o "un.$(UnLyXPreferencesTitle)" un.SecUnPreferences
114
115  # remove LyX's config files
116  StrCpy $AppSubfolder ${APP_DIR_USERDATA}
117  Call un.DelAppPathSub # function from LyXUtils.nsh
118  # remove registry settings
119  DeleteRegKey HKCU "Software\LyX\LyX${APP_SERIES_NAME}"
120   
121 SectionEnd
122
123 #---------------------------------
124 # MiKTeX
125 Section "un.MiKTeX" un.SecUnMiKTeX
126
127  ${if} $LaTeXInstalled == "MiKTeX" # only uninstall MiKTeX when it was installed together with LyX 
128   ReadRegStr $1 SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\MiKTeX ${MiKTeXDeliveredVersion}" "UninstallString"
129   ExecWait $1 # run MiKTeX's uninstaller
130  ${endif}
131
132 SectionEnd
133
134 #---------------------------------
135 # JabRef
136 Section "un.JabRef" un.SecUnJabRef
137
138  ${if} $JabRefInstalled == "Yes" # only uninstall JabRef when it was installed together with LyX
139   ${If} $MultiUser.Privileges == "Admin"
140   ${OrIf} $MultiUser.Privileges == "Power"
141    ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef" "UninstallString"
142    IfSilent 0 +2
143    ExecWait "$1 /S" # run JabRef's uninstaller
144    ExecWait "$1" # run JabRef's uninstaller
145    DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef"
146   ${else}
147    ReadRegStr $1 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef" "UninstallString"
148    IfSilent 0 +2
149    ExecWait "$1 /S" # run JabRef's uninstaller
150    ExecWait "$1" # run JabRef's uninstaller
151    DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef"
152   ${endif}
153  ${endif}
154
155 SectionEnd
156
157 #---------------------------------
158 # Section descriptions
159 !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
160 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnMiKTeX} "$(SecUnMiKTeXDescription)"
161 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnJabRef} "$(SecUnJabRefDescription)"
162 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnPreferences} "$(SecUnPreferencesDescription)"
163 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnProgramFiles} "$(SecUnProgramFilesDescription)"
164 !insertmacro MUI_UNFUNCTION_DESCRIPTION_END
165
166 #Section "un.User Preferences and Custom Files" un.SecUserFiles
167 #
168 #  SetShellVarContext current
169 #  RMDir /r "$APPDATA\${APP_DIR_USERDATA}"
170 #  
171 #SectionEnd