]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/uninstall.nsh
Win installer: 2 fixes for the uninstaller
[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}"
61     DeleteRegKey SHCTX "Software\Classes\${APP_REGNAME_DOC}"
62    ${endif}
63   ${endif}
64   ${if} $MultiUser.Privileges == "Admin"
65    DeleteRegKey HKCR "LyX.Document"
66   ${endif}
67
68   # Uninstaller itself
69   Delete "$INSTDIR\${SETUP_UNINSTALLER}"
70   
71   # Application folder
72   SetOutPath "$TEMP"
73   RMDir /r "$INSTDIR"
74   
75   # Registry keys
76   DeleteRegKey SHCTX "${APP_REGKEY_SETUP}"
77   DeleteRegKey SHCTX "${APP_REGKEY}"
78   DeleteRegKey SHCTX "${APP_UNINST_KEY}"
79   DeleteRegKey HKCR "Applications\lyx.exe"
80   
81   # File associations
82   ReadRegStr $FileAssociation SHELL_CONTEXT "Software\Classes\${APP_EXT}" ""
83   
84   ${If} $FileAssociation == "${APP_REGNAME_DOC}"
85      DeleteRegKey SHELL_CONTEXT "Software\Classes\${APP_EXT}"
86   ${EndIf}
87   
88   ${If} $MultiUser.Privileges == "Admin"
89   ${OrIf} $MultiUser.Privileges == "Power"
90    # Delete Postscript printer for metafile to EPS conversion
91    ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
92   ${EndIf}
93   
94   # clean other registry entries
95   DeleteRegKey SHCTX "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\${APP_NAME}.exe"
96   DeleteRegKey SHCTX "SOFTWARE\${APP_REGKEY}"
97   
98   # delete info that programs were installed together with LyX
99   DeleteRegValue SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
100   DeleteRegValue SHCTX "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"  
101
102 SectionEnd
103
104 #---------------------------------
105 # user preferences
106 Section /o "un.$(UnLyXPreferencesTitle)" un.SecUnPreferences
107
108  # remove LyX's config files
109  StrCpy $AppSubfolder ${APP_DIR_USERDATA}
110  Call un.DelAppPathSub # function from LyXUtils.nsh
111   
112 SectionEnd
113
114 #---------------------------------
115 # MiKTeX
116 Section /o "un.MiKTeX" un.SecUnMiKTeX
117
118  ${if} $LaTeXInstalled == "MiKTeX" # only uninstall MiKTeX when it was installed together with LyX 
119   ReadRegStr $1 SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\MiKTeX ${MiKTeXDeliveredVersion}" "UninstallString"
120   ExecWait $1 # run MiKTeX's uninstaller
121  ${endif}
122
123 SectionEnd
124
125 #---------------------------------
126 # JabRef
127 Section "un.JabRef" un.SecUnJabRef
128
129  ${if} $JabRefInstalled == "Yes" # only uninstall JabRef when it was installed together with LyX
130   ${If} $MultiUser.Privileges == "Admin"
131   ${OrIf} $MultiUser.Privileges == "Power"
132    ReadRegStr $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "UninstallString"
133    IfSilent 0 +2
134    ExecWait "$1 /S" # run JabRef's uninstaller
135    ExecWait "$1" # run JabRef's uninstaller
136   ${else}
137    # in this case we can only read the start menu location and then start the linked uninstaller
138    ReadRegStr $1 HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "StartMenu"
139    StrCpy $1 "$1\Uninstall JabRef "${JabRefVersion}".lnk"
140    ExecShell "" "$1" # run JabRef's uninstaller
141   ${endif}
142  ${endif}
143
144 SectionEnd
145
146 #---------------------------------
147 # Section descriptions
148 !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
149 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnMiKTeX} "$(SecUnMiKTeXDescription)"
150 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnJabRef} "$(SecUnJabRefDescription)"
151 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnPreferences} "$(SecUnPreferencesDescription)"
152 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnProgramFiles} "$(SecUnProgramFilesDescription)"
153 !insertmacro MUI_UNFUNCTION_DESCRIPTION_END
154
155 #Section "un.User Preferences and Custom Files" un.SecUserFiles
156 #
157 #  SetShellVarContext current
158 #  RMDir /r "$APPDATA\${APP_DIR_USERDATA}"
159 #  
160 #SectionEnd