PortableApps: Exclude a bunch of files.
[metze/wireshark/wip.git] / packaging / nsis / uninstall.nsi
1 ;
2 ; uninstall.nsi
3 ;
4
5 ; Create an installer that only writes an uninstaller.
6 ; http://nsis.sourceforge.net/Signing_an_Uninstaller
7
8 !include "common.nsh"
9 !include 'LogicLib.nsh'
10 !include x64.nsh
11 !include "StrFunc.nsh"
12 ${UnStrRep}
13
14 SetCompress off
15 OutFile "${STAGING_DIR}\uninstall_installer.exe"
16 RequestExecutionLevel user
17
18 InstType "un.Default (keep Personal Settings and WinPcap)"
19 InstType "un.All (remove all)"
20
21 ; Uninstaller icon
22 UninstallIcon "..\..\image\wiresharkinst.ico"
23
24 !include "MUI.nsh"
25
26 !define MUI_UNICON "..\..\image\wiresharkinst.ico"
27
28 ; Uninstall stuff (NSIS 2.08: "\r\n" don't work here)
29 !define MUI_UNCONFIRMPAGE_TEXT_TOP "The following ${PROGRAM_NAME} installation will be removed. Click 'Next' to continue."
30 ; Uninstall stuff (this text isn't used with the MODERN_UI!)
31 ;UninstallText "This will uninstall ${PROGRAM_NAME}.\r\nBefore starting the uninstallation, make sure ${PROGRAM_NAME} is not running.\r\nClick 'Next' to continue."
32
33 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
34
35 !insertmacro MUI_UNPAGE_WELCOME
36 !insertmacro MUI_UNPAGE_CONFIRM
37 !insertmacro MUI_UNPAGE_COMPONENTS
38 !insertmacro MUI_UNPAGE_INSTFILES
39 !insertmacro MUI_UNPAGE_FINISH
40
41 !insertmacro MUI_LANGUAGE "English"
42
43 ; ============================================================================
44 ; Section macros
45 ; ============================================================================
46 !include "Sections.nsh"
47
48 ; ============================================================================
49 ; Uninstall page configuration
50 ; ============================================================================
51 ShowUninstDetails show
52
53 ; ============================================================================
54 ; Functions and macros
55 ; ============================================================================
56
57 Function .onInit
58   ; MUST be the absolute path to our staging directory.
59   WriteUninstaller "${STAGING_DIR}\${UNINSTALLER_NAME}"
60   SetErrorLevel 0
61   Quit
62 FunctionEnd
63
64 Var EXTENSION
65 Function un.Disassociate
66     Push $R0
67 !insertmacro PushFileExtensions
68
69     Pop $EXTENSION
70     ${DoUntil} $EXTENSION == ${FILE_EXTENSION_MARKER}
71         ReadRegStr $R0 HKCR $EXTENSION ""
72         StrCmp $R0 ${WIRESHARK_ASSOC} un.Disassociate.doDeregister
73         Goto un.Disassociate.end
74 un.Disassociate.doDeregister:
75         ; The extension is associated with Wireshark so, we must destroy this!
76         DeleteRegKey HKCR $EXTENSION
77         DetailPrint "Deregistered file type: $EXTENSION"
78 un.Disassociate.end:
79         Pop $EXTENSION
80     ${Loop}
81
82     Pop $R0
83 FunctionEnd
84
85 Section "-Required"
86 SectionEnd
87
88 !define EXECUTABLE_MARKER "EXECUTABLE_MARKER"
89 Var EXECUTABLE
90
91 Section /o "Un.USBPcap" un.SecUSBPcap
92 ;-------------------------------------------
93 SectionIn 2
94 ${If} ${RunningX64}
95     ${DisableX64FSRedirection}
96     SetRegView 64
97 ${EndIf}
98 ReadRegStr $1 HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\USBPcap" "UninstallString"
99 ${If} ${RunningX64}
100     ${EnableX64FSRedirection}
101     SetRegView 32
102 ${EndIf}
103 ${If} $1 != ""
104     ${UnStrRep} $2 '$1' '\Uninstall.exe' ''
105     ${UnStrRep} $3 '$2' '"' ''
106     ExecWait '$1 _?=$3' $0
107     DetailPrint "USBPcap uninstaller returned $0"
108     ${If} $0 == "0"
109         Delete "$3\Uninstall.exe"
110         Delete "$INSTDIR\extcap\USBPcapCMD.exe"
111     ${EndIf}
112 ${EndIf}
113 ClearErrors
114 SectionEnd
115
116
117 Section "Uninstall" un.SecUinstall
118 ;-------------------------------------------
119 ;
120 ; UnInstall for every user
121 ;
122 SectionIn 1 2
123 SetShellVarContext all
124
125 !insertmacro IsWiresharkRunning
126
127 Push "${EXECUTABLE_MARKER}"
128 Push "androiddump"
129 Push "ciscodump"
130 Push "sshdump"
131 Push "udpdump"
132 Push "dumpcap"
133 Push "${PROGRAM_NAME}"
134 Push "tshark"
135 Push "qtshark"
136 Push "editcap"
137 Push "text2pcap"
138 Push "mergecap"
139 Push "randpktdump"
140 Push "reordercap"
141 Push "capinfos"
142 Push "rawshark"
143 Push "dftest"
144
145 Pop $EXECUTABLE
146 ${DoUntil} $EXECUTABLE == ${EXECUTABLE_MARKER}
147
148     ; IsWiresharkRunning should make sure everything is closed down so we *shouldn't* run
149     ; into any problems here.
150     Delete "$INSTDIR\$EXECUTABLE.exe"
151     IfErrors 0 deletionSuccess
152         MessageBox MB_OK "$EXECUTABLE.exe could not be removed. Is it in use?" /SD IDOK IDOK 0
153         Abort "$EXECUTABLE.exe could not be removed. Aborting the uninstall process."
154
155 deletionSuccess:
156     Pop $EXECUTABLE
157
158 ${Loop}
159
160
161 DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}"
162 DeleteRegKey HKEY_LOCAL_MACHINE "Software\${PROGRAM_NAME}"
163 DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\${PROGRAM_NAME}.exe"
164
165 Call un.Disassociate
166
167 DeleteRegKey HKCR ${WIRESHARK_ASSOC}
168 DeleteRegKey HKCR "${WIRESHARK_ASSOC}\Shell\open\command"
169 DeleteRegKey HKCR "${WIRESHARK_ASSOC}\DefaultIcon"
170
171 Delete "$INSTDIR\*.dll"
172 Delete "$INSTDIR\*.exe"
173 Delete "$INSTDIR\*.html"
174 Delete "$INSTDIR\*.qm"
175 Delete "$INSTDIR\accessible\*.*"
176 Delete "$INSTDIR\AUTHORS-SHORT"
177 Delete "$INSTDIR\COPYING*"
178 Delete "$INSTDIR\audio\*.*"
179 Delete "$INSTDIR\bearer\*.*"
180 Delete "$INSTDIR\diameter\*.*"
181 Delete "$INSTDIR\etc\gtk-2.0\*.*"
182 Delete "$INSTDIR\etc\gtk-3.0\*.*"
183 Delete "$INSTDIR\etc\pango\*.*"
184 Delete "$INSTDIR\extcap\androiddump.*"
185 Delete "$INSTDIR\extcap\randpktdump.*"
186 Delete "$INSTDIR\extcap\sshdump.*"
187 Delete "$INSTDIR\extcap\ciscodump.*"
188 Delete "$INSTDIR\extcap\udpdump.*"
189 Delete "$INSTDIR\help\*.*"
190 Delete "$INSTDIR\iconengines\*.*"
191 Delete "$INSTDIR\imageformats\*.*"
192 Delete "$INSTDIR\lib\gtk-2.0\2.10.0\engines\*.*"
193 Delete "$INSTDIR\lib\gtk-2.0\2.10.0\immodules\*.*"
194 Delete "$INSTDIR\lib\gtk-2.0\2.10.0\loaders\*.*"
195 Delete "$INSTDIR\lib\gtk-2.0\2.2.0\engines\*.*"
196 Delete "$INSTDIR\lib\gtk-2.0\2.2.0\immodules\*.*"
197 Delete "$INSTDIR\lib\gtk-2.0\2.2.0\loaders\*.*"
198 Delete "$INSTDIR\lib\gtk-2.0\2.4.0\engines\*.*"
199 Delete "$INSTDIR\lib\gtk-2.0\2.4.0\immodules\*.*"
200 Delete "$INSTDIR\lib\gtk-2.0\2.4.0\loaders\*.*"
201 Delete "$INSTDIR\lib\gtk-2.0\modules\*.*"
202 Delete "$INSTDIR\lib\pango\1.2.0\modules\*.*"
203 Delete "$INSTDIR\lib\pango\1.4.0\modules\*.*"
204 Delete "$INSTDIR\lib\pango\1.5.0\modules\*.*"
205 Delete "$INSTDIR\mediaservice\*.*"
206 Delete "$INSTDIR\platforms\*.*"
207 Delete "$INSTDIR\playlistformats\*.*"
208 Delete "$INSTDIR\printsupport\*.*"
209 Delete "$INSTDIR\share\glib-2.0\schemas\*.*"
210 Delete "$INSTDIR\share\themes\Default\gtk-2.0\*.*"
211 Delete "$INSTDIR\snmp\*.*"
212 Delete "$INSTDIR\snmp\mibs\*.*"
213 Delete "$INSTDIR\tpncp\*.*"
214 Delete "$INSTDIR\translations\*.*"
215 Delete "$INSTDIR\ui\*.*"
216 Delete "$INSTDIR\wimaxasncp\*.*"
217 Delete "$INSTDIR\ws.css"
218 ; previous versions installed these files
219 Delete "$INSTDIR\*.manifest"
220 ; previous versions installed this file
221 Delete "$INSTDIR\AUTHORS-SHORT-FORMAT"
222 Delete "$INSTDIR\README*"
223 Delete "$INSTDIR\NEWS.txt"
224 Delete "$INSTDIR\manuf"
225 Delete "$INSTDIR\wka"
226 Delete "$INSTDIR\services"
227 Delete "$INSTDIR\pdml2html.xsl"
228 Delete "$INSTDIR\pcrepattern.3.txt"
229 Delete "$INSTDIR\user-guide.chm"
230 Delete "$INSTDIR\example_snmp_users_file"
231 Delete "$INSTDIR\ipmap.html"
232 Delete "$INSTDIR\radius\*.*"
233 Delete "$INSTDIR\dtds\*.*"
234 Delete "$SMPROGRAMS\${PROGRAM_NAME}\*.*"
235 Delete "$SMPROGRAMS\${PROGRAM_NAME}.lnk"
236 Delete "$SMPROGRAMS\${PROGRAM_NAME_GTK}.lnk"
237 Delete "$SMPROGRAMS\${PROGRAM_NAME_QT}.lnk"
238 Delete "$SMPROGRAMS\Qtshark.lnk"
239 Delete "$DESKTOP\${PROGRAM_NAME}.lnk"
240 Delete "$DESKTOP\${PROGRAM_NAME_GTK}.lnk"
241 Delete "$DESKTOP\${PROGRAM_NAME_QT}.lnk"
242 Delete "$QUICKLAUNCH\${PROGRAM_NAME}.lnk"
243 Delete "$QUICKLAUNCH\${PROGRAM_NAME_GTK}.lnk"
244 Delete "$QUICKLAUNCH\${PROGRAM_NAME_QT}.lnk"
245
246 RMDir "$INSTDIR\accessible"
247 RMDir "$INSTDIR\audio"
248 RMDir "$INSTDIR\bearer"
249 RMDir "$INSTDIR\etc\gtk-2.0"
250 RMDir "$INSTDIR\etc\pango"
251 RMDir "$INSTDIR\etc"
252 RMDir "$INSTDIR\extcap"
253 RMDir "$INSTDIR\iconengines"
254 RMDir "$INSTDIR\imageformats"
255 RMDir "$INSTDIR\lib\gtk-2.0\2.2.0\engines"
256 RMDir "$INSTDIR\lib\gtk-2.0\2.2.0\loaders"
257 RMDir "$INSTDIR\lib\gtk-2.0\2.2.0\immodules"
258 RMDir "$INSTDIR\lib\gtk-2.0\2.2.0"
259 RMDir "$INSTDIR\lib\gtk-2.0\2.4.0\engines"
260 RMDir "$INSTDIR\lib\gtk-2.0\2.4.0\loaders"
261 RMDir "$INSTDIR\lib\gtk-2.0\2.4.0\immodules"
262 RMDir "$INSTDIR\lib\gtk-2.0\2.4.0"
263 RMDir "$INSTDIR\lib\gtk-2.0\2.10.0\engines"
264 RMDir "$INSTDIR\lib\gtk-2.0\2.10.0\loaders"
265 RMDir "$INSTDIR\lib\gtk-2.0\2.10.0\immodules"
266 RMDir "$INSTDIR\lib\gtk-2.0\2.10.0"
267 RMDir "$INSTDIR\lib\gtk-2.0\modules"
268 RMDir "$INSTDIR\lib\gtk-2.0"
269 RMDir "$INSTDIR\lib\pango\1.2.0\modules"
270 RMDir "$INSTDIR\lib\pango\1.2.0"
271 RMDir "$INSTDIR\lib\pango\1.4.0\modules"
272 RMDir "$INSTDIR\lib\pango\1.4.0"
273 RMDir "$INSTDIR\lib\pango\1.5.0\modules"
274 RMDir "$INSTDIR\lib\pango\1.5.0"
275 RMDir "$INSTDIR\lib\pango"
276 RMDir "$INSTDIR\lib"
277 RMDir "$INSTDIR\mediaservice"
278 RMDir "$INSTDIR\platforms"
279 RMDir "$INSTDIR\playlistformats"
280 RMDir "$INSTDIR\printsupport"
281 RMDir "$INSTDIR\share\themes\Default\gtk-2.0"
282 RMDir "$INSTDIR\share\themes\Default"
283 RMDir "$INSTDIR\share\themes"
284 RMDir "$INSTDIR\share"
285 RMDir "$SMPROGRAMS\${PROGRAM_NAME}"
286 RMDir "$INSTDIR\help"
287 RMDir "$INSTDIR\diameter"
288 RMDir "$INSTDIR\snmp\mibs"
289 RMDir "$INSTDIR\snmp"
290 RMDir "$INSTDIR\radius"
291 RMDir "$INSTDIR\dtds"
292 RMDir "$INSTDIR\tpncp"
293 RMDir "$INSTDIR\translations"
294 RMDir "$INSTDIR\ui"
295 RMDir "$INSTDIR\wimaxasncp"
296 RMDir "$INSTDIR"
297
298 SectionEnd ; "Uinstall"
299
300 Section "Un.Plugins" un.SecPlugins
301 ;-------------------------------------------
302 SectionIn 1 2
303 ;Delete "$INSTDIR\plugins\${VERSION}\*.*"
304 ;Delete "$INSTDIR\plugins\*.*"
305 ;RMDir "$INSTDIR\plugins\${VERSION}"
306 ;RMDir "$INSTDIR\plugins"
307 RMDir /r "$INSTDIR\plugins"
308 SectionEnd
309
310 Section "Un.Global Profiles" un.SecProfiles
311 ;-------------------------------------------
312 SectionIn 1 2
313 RMDir /r "$INSTDIR\profiles"
314 SectionEnd
315
316 Section "Un.Global Settings" un.SecGlobalSettings
317 ;-------------------------------------------
318 SectionIn 1 2
319 Delete "$INSTDIR\cfilters"
320 Delete "$INSTDIR\colorfilters"
321 Delete "$INSTDIR\dfilters"
322 Delete "$INSTDIR\enterprises.tsv"
323 Delete "$INSTDIR\init.lua"
324 Delete "$INSTDIR\console.lua"
325 Delete "$INSTDIR\dtd_gen.lua"
326 Delete "$INSTDIR\smi_modules"
327 RMDir "$INSTDIR"
328 SectionEnd
329
330 Section /o "Un.Personal Settings" un.SecPersonalSettings
331 ;-------------------------------------------
332 SectionIn 2
333 SetShellVarContext current
334 Delete "$APPDATA\${PROGRAM_NAME}\*.*"
335 RMDir "$APPDATA\${PROGRAM_NAME}"
336 DeleteRegKey HKCU "Software\${PROGRAM_NAME}"
337 SectionEnd
338
339 ;VAR un.WINPCAP_UNINSTALL
340
341 Section /o "Un.WinPcap" un.SecWinPcap
342 ;-------------------------------------------
343 SectionIn 2
344 ReadRegStr $1 HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WinPcapInst" "UninstallString"
345 ;IfErrors un.lbl_winpcap_notinstalled ;if RegKey is unavailable, WinPcap is not installed
346 ${If} $1 != ""
347     ;MessageBox MB_OK "WinPcap $1" /SD IDOK
348     ExecWait '$1' $0
349     DetailPrint "WinPcap uninstaller returned $0"
350     ;SetRebootFlag true
351 ${EndIf}
352 ;un.lbl_winpcap_notinstalled:
353 SectionEnd
354
355 Section "-Un.Finally"
356 ;-------------------------------------------
357 SectionIn 1 2
358
359 !insertmacro UpdateIcons
360
361 ; this test must be done after all other things uninstalled (e.g. Global Settings)
362 IfFileExists "$INSTDIR" 0 NoFinalErrorMsg
363     MessageBox MB_OK "Unable to remove $INSTDIR." /SD IDOK IDOK 0 ; skipped if dir doesn't exist
364 NoFinalErrorMsg:
365 SectionEnd
366
367 !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
368     !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUinstall} "Uninstall all ${PROGRAM_NAME} components."
369     !insertmacro MUI_DESCRIPTION_TEXT ${un.SecPlugins} "Uninstall all Plugins (even from previous ${PROGRAM_NAME} versions)."
370     !insertmacro MUI_DESCRIPTION_TEXT ${un.SecProfiles} "Uninstall all global configuration profiles."
371     !insertmacro MUI_DESCRIPTION_TEXT ${un.SecGlobalSettings} "Uninstall global settings like: $INSTDIR\cfilters"
372     !insertmacro MUI_DESCRIPTION_TEXT ${un.SecPersonalSettings} "Uninstall personal settings like your preferences file from your profile: $PROFILE."
373     !insertmacro MUI_DESCRIPTION_TEXT ${un.SecWinPcap} "Call WinPcap's uninstall program."
374     !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUSBPcap} "Call USBPcap's uninstall program."
375 !insertmacro MUI_UNFUNCTION_DESCRIPTION_END
376
377 ;
378 ; Editor modelines  -  http://www.wireshark.org/tools/modelines.html
379 ;
380 ; Local variables:
381 ; c-basic-offset: 4
382 ; tab-width: 8
383 ; indent-tabs-mode: nil
384 ; End:
385 ;
386 ; vi: set shiftwidth=4 tabstop=8 expandtab:
387 ; :indentSize=4:tabSize=8:noTabs=true:
388 ;