]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/uninstall.nsh
Consider inset strings in simple find/replaceAll (#12049)
[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   
36   # Components of Ghostscript
37   RMDir /r "$INSTDIR\ghostscript"
38   
39   # delete start menu folder
40   ReadRegStr $0 SHCTX "${APP_UNINST_KEY}" "StartMenu"
41   RMDir /r "$0"
42   # delete desktop icon
43   Delete "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
44   
45   # remove file extension .lyx
46   ReadRegStr $0 SHCTX "${APP_DIR_REGKEY}" "OnlyWithLyX" # test if they were registered by this LyX version
47   ${if} $0 == "Yes${APP_SERIES_KEY}"
48    ReadRegStr $R0 SHCTX "Software\Classes\${APP_EXT}" ""
49    ${if} $R0 == "${APP_REGNAME_DOC}"
50     #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}13"
51     #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}14"
52     #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}15"
53     #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}16"
54     #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}20"
55     #DeleteRegKey SHCTX "Software\Classes\${APP_EXT}21"
56     DeleteRegKey SHCTX "Software\Classes\${APP_EXT}"
57     #DeleteRegKey SHCTX "Software\Classes\${APP_REGNAME_DOC}"
58    ${endif}
59   ${endif}
60   ${if} $MultiUser.Privileges == "Admin"
61    DeleteRegKey HKCR "${APP_NAME}.Document"
62   ${endif}
63
64   # Uninstaller itself
65   Delete "$INSTDIR\${SETUP_UNINSTALLER}"
66   
67   # Application folder
68   SetOutPath "$TEMP"
69   RMDir /r "$INSTDIR"
70   
71   # Registry keys and values
72   DeleteRegValue SHCTX "subkey" "key_name"
73   DeleteRegKey SHCTX "${APP_REGKEY_SETUP}"
74   DeleteRegKey SHCTX "${APP_REGKEY}"
75   DeleteRegKey SHCTX "${APP_UNINST_KEY}"
76   DeleteRegKey HKCR "Applications\${BIN_LYX}"
77   DeleteRegValue HKCR "${APP_NAME}.Document\Shell\open\command" ""
78   DeleteRegValue HKCR "${APP_NAME}.Document\DefaultIcon" ""
79   ReadRegStr $0 SHCTX ${APP_REGFOLDER} "latestVersion"
80   ${If} $0 == ${APP_SERIES_KEY}
81     DeleteRegValue SHCTX ${APP_REGFOLDER} "latestVersion"
82     StrCpy $0 0
83     StrCpy $R0 ""
84     ${Do}
85       StrCpy $R1 $R0
86       EnumRegKey $R0 SHCTX ${APP_REGFOLDER} $0
87       IntOp $0 $0 + 1
88     ${LoopUntil} $R0 == ""
89     ${If} $R1 != ""
90       WriteRegStr SHCTX ${APP_REGFOLDER} "latestVersion" $R1
91     ${EndIf}
92   ${EndIf}
93   DeleteRegKey /ifempty SHCTX ${APP_REGFOLDER}
94   
95   # File associations
96   ReadRegStr $FileAssociation SHELL_CONTEXT "Software\Classes\${APP_EXT}" ""
97   
98   ${If} $FileAssociation == "${APP_REGNAME_DOC}"
99      DeleteRegKey SHELL_CONTEXT "Software\Classes\${APP_EXT}"
100   ${EndIf}
101   
102   # clean other registry entries
103   DeleteRegKey SHCTX "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\${APP_NAME}.exe"
104   DeleteRegKey SHCTX "SOFTWARE\${APP_REGKEY}"
105   
106   # delete info that programs were installed together with LyX
107   DeleteRegValue SHCTX "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
108   
109   # for texindy the path to the perl.exe must unfortunately be in Windows' PATH variable
110   # so we have to remove it now
111   ${if} $MultiUser.Privileges != "Admin"
112   ${andif} $MultiUser.Privileges != "Power"
113    # call the non-admin version
114    ${un.EnvVarUpdate} $0 "PATH" "R" "HKCU" "$INSTDIR\Perl\bin"
115   ${else}
116    ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\Perl\bin"
117   ${endif}
118
119 SectionEnd
120
121 #---------------------------------
122 # user preferences
123 Section /o "un.$(UnLyXPreferencesTitle)" un.SecUnPreferences
124
125  # remove LyX's config files
126  StrCpy $AppSubfolder ${APP_DIR_USERDATA}
127  Call un.DelAppPathSub # function from LyXUtils.nsh
128  # remove registry settings
129  DeleteRegKey HKCU "Software\${APP_NAME}\${APP_NAME}${APP_SERIES_NAME}"
130   
131 SectionEnd
132
133 #---------------------------------
134 # MiKTeX
135 Section "un.MiKTeX" un.SecUnMiKTeX
136
137  ${if} $LaTeXInstalled == "MiKTeX" # only uninstall MiKTeX when it was installed together with LyX 
138   ReadRegStr $1 SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\MiKTeX ${MiKTeXDeliveredVersion}" "UninstallString"
139   ExecWait $1 # run MiKTeX's uninstaller
140  ${endif}
141
142 SectionEnd
143
144 #---------------------------------
145 # Section descriptions
146 !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
147 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnMiKTeX} "$(SecUnMiKTeXDescription)"
148 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnPreferences} "$(SecUnPreferencesDescription)"
149 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnProgramFiles} "$(SecUnProgramFilesDescription)"
150 !insertmacro MUI_UNFUNCTION_DESCRIPTION_END
151
152 #Section "un.User Preferences and Custom Files" un.SecUserFiles
153 #
154 #  SetShellVarContext current
155 #  RMDir /r "$APPDATA\${APP_DIR_USERDATA}"
156 #  
157 #SectionEnd