Source code

Revision control

Other Tools

1
# This Source Code Form is subject to the terms of the Mozilla Public
2
# License, v. 2.0. If a copy of the MPL was not distributed with this
3
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5
# Required Plugins:
11
12
; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs
13
!verbose 3
14
15
; 7-Zip provides better compression than the lzma from NSIS so we add the files
16
; uncompressed and use 7-Zip to create a SFX archive of it
17
SetDatablockOptimize on
18
SetCompress off
19
CRCCheck on
20
21
RequestExecutionLevel user
22
23
Unicode true
24
ManifestSupportedOS all
25
ManifestDPIAware true
26
27
!addplugindir ./
28
29
; Attempt to elevate Standard Users in addition to users that
30
; are a member of the Administrators group.
31
!define NONADMIN_ELEVATE
32
33
; prevents compiling of the reg write logging.
34
!define NO_LOG
35
36
!define MaintUninstallKey \
37
"Software\Microsoft\Windows\CurrentVersion\Uninstall\MozillaMaintenanceService"
38
39
Var TmpVal
40
Var MaintCertKey
41
Var ShouldOpenSurvey
42
; AddTaskbarSC is defined here in order to silence warnings from inside
43
; MigrateTaskBarShortcut and is not intended to be used here.
44
; See Bug 1329869 for more.
45
Var AddTaskbarSC
46
47
; Other included files may depend upon these includes!
48
; The following includes are provided by NSIS.
49
!include FileFunc.nsh
50
!include LogicLib.nsh
51
!include MUI.nsh
52
!include WinMessages.nsh
53
!include WinVer.nsh
54
!include WordFunc.nsh
55
56
!insertmacro GetSize
57
!insertmacro StrFilter
58
!insertmacro WordReplace
59
60
!insertmacro un.GetParent
61
62
; The following includes are custom.
63
!include branding.nsi
64
!include defines.nsi
65
!include common.nsh
66
!include locales.nsi
67
68
; This is named BrandShortName helper because we use this for software update
69
; post update cleanup.
70
VIAddVersionKey "FileDescription" "${BrandShortName} Helper"
71
VIAddVersionKey "OriginalFilename" "helper.exe"
72
73
!insertmacro AddDisabledDDEHandlerValues
74
!insertmacro CleanVirtualStore
75
!insertmacro ElevateUAC
76
!insertmacro GetLongPath
77
!insertmacro GetPathFromString
78
!insertmacro InitHashAppModelId
79
!insertmacro IsHandlerForInstallDir
80
!insertmacro IsPinnedToTaskBar
81
!insertmacro IsUserAdmin
82
!insertmacro LogDesktopShortcut
83
!insertmacro LogQuickLaunchShortcut
84
!insertmacro LogStartMenuShortcut
85
!insertmacro PinnedToStartMenuLnkCount
86
!insertmacro RegCleanAppHandler
87
!insertmacro RegCleanMain
88
!insertmacro RegCleanUninstall
89
!insertmacro SetAppLSPCategories
90
!insertmacro SetBrandNameVars
91
!insertmacro UpdateShortcutAppModelIDs
92
!insertmacro UnloadUAC
93
!insertmacro WriteRegDWORD2
94
!insertmacro WriteRegStr2
95
96
; This needs to be inserted after InitHashAppModelId because it uses
97
; $AppUserModelID and the compiler can't handle using variables lexically before
98
; they've been declared.
99
!insertmacro GetInstallerRegistryPref
100
101
!insertmacro un.ChangeMUIHeaderImage
102
!insertmacro un.ChangeMUISidebarImage
103
!insertmacro un.CheckForFilesInUse
104
!insertmacro un.CleanUpdateDirectories
105
!insertmacro un.CleanVirtualStore
106
!insertmacro un.DeleteShortcuts
107
!insertmacro un.GetLongPath
108
!insertmacro un.GetSecondInstallPath
109
!insertmacro un.InitHashAppModelId
110
!insertmacro un.ManualCloseAppPrompt
111
!insertmacro un.RegCleanAppHandler
112
!insertmacro un.RegCleanFileHandler
113
!insertmacro un.RegCleanMain
114
!insertmacro un.RegCleanPrefs
115
!insertmacro un.RegCleanUninstall
116
!insertmacro un.RegCleanProtocolHandler
117
!insertmacro un.RemoveQuotesFromPath
118
!insertmacro un.RemovePrecompleteEntries
119
!insertmacro un.SetAppLSPCategories
120
!insertmacro un.SetBrandNameVars
121
122
!include shared.nsh
123
124
; Helper macros for ui callbacks. Insert these after shared.nsh
125
!insertmacro OnEndCommon
126
!insertmacro UninstallOnInitCommon
127
128
!insertmacro un.OnEndCommon
129
!insertmacro un.UninstallUnOnInitCommon
130
131
Name "${BrandFullName}"
132
OutFile "helper.exe"
133
!ifdef HAVE_64BIT_BUILD
134
InstallDir "$PROGRAMFILES64\${BrandFullName}\"
135
!else
136
InstallDir "$PROGRAMFILES32\${BrandFullName}\"
137
!endif
138
ShowUnInstDetails nevershow
139
141
142
################################################################################
143
# Modern User Interface - MUI
144
145
!define MUI_ABORTWARNING
146
!define MUI_ICON setup.ico
147
!define MUI_UNICON setup.ico
148
!define MUI_WELCOMEPAGE_TITLE_3LINES
149
!define MUI_HEADERIMAGE
150
!define MUI_HEADERIMAGE_RIGHT
151
!define MUI_UNWELCOMEFINISHPAGE_BITMAP wizWatermark.bmp
152
; By default MUI_BGCOLOR is hardcoded to FFFFFF, which is only correct if the
153
; the Windows theme or high-contrast mode hasn't changed it, so we need to
154
; override that with GetSysColor(COLOR_WINDOW) (this string ends up getting
155
; passed to SetCtlColors, which uses this custom syntax to mean that).
156
!define MUI_BGCOLOR SYSCLR:WINDOW
157
158
; Use a right to left header image when the language is right to left
159
!ifdef ${AB_CD}_rtl
160
!define MUI_HEADERIMAGE_BITMAP_RTL wizHeaderRTL.bmp
161
!else
162
!define MUI_HEADERIMAGE_BITMAP wizHeader.bmp
163
!endif
164
165
/**
166
* Uninstall Pages
167
*/
168
; Welcome Page
169
!define MUI_PAGE_CUSTOMFUNCTION_PRE un.preWelcome
170
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.showWelcome
171
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.leaveWelcome
172
!insertmacro MUI_UNPAGE_WELCOME
173
174
; Custom Uninstall Confirm Page
175
UninstPage custom un.preConfirm
176
177
; Remove Files Page
178
!insertmacro MUI_UNPAGE_INSTFILES
179
180
; Finish Page
181
!define MUI_FINISHPAGE_SHOWREADME
182
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
183
!define MUI_FINISHPAGE_SHOWREADME_TEXT $(UN_SURVEY_CHECKBOX_LABEL)
184
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION un.Survey
185
!define MUI_PAGE_CUSTOMFUNCTION_PRE un.preFinish
186
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.showFinish
187
!insertmacro MUI_UNPAGE_FINISH
188
189
; Use the default dialog for IDD_VERIFY for a simple Banner
190
ChangeUI IDD_VERIFY "${NSISDIR}\Contrib\UIs\default.exe"
191
192
################################################################################
193
# Helper Functions
194
195
Function un.Survey
196
; We can't actually call ExecInExplorer here because it's going to have to
197
; make some marshalled COM calls and those are not allowed from within a
198
; synchronous message handler (where we currently are); we'll be thrown
199
; RPC_E_CANTCALLOUT_ININPUTSYNCCALL if we try. So all we can do is record
200
; that we need to make the call later, which we'll do from un.onGUIEnd.
201
StrCpy $ShouldOpenSurvey "1"
202
FunctionEnd
203
204
; This function is used to uninstall the maintenance service if the
205
; application currently being uninstalled is the last application to use the
206
; maintenance service.
207
Function un.UninstallServiceIfNotUsed
208
; $0 will store if a subkey exists
209
; $1 will store the first subkey if it exists or an empty string if it doesn't
210
; Backup the old values
211
Push $0
212
Push $1
213
214
; The maintenance service always uses the 64-bit registry on x64 systems
215
${If} ${RunningX64}
216
${OrIf} ${IsNativeARM64}
217
SetRegView 64
218
${EndIf}
219
220
; Figure out the number of subkeys
221
StrCpy $0 0
222
${Do}
223
EnumRegKey $1 HKLM "Software\Mozilla\MaintenanceService" $0
224
${If} "$1" == ""
225
${ExitDo}
226
${EndIf}
227
IntOp $0 $0 + 1
228
${Loop}
229
230
; Restore back the registry view
231
${If} ${RunningX64}
232
${OrIf} ${IsNativeARM64}
233
SetRegView lastUsed
234
${EndIf}
235
236
${If} $0 == 0
237
; Get the path of the maintenance service uninstaller.
238
; Look in both the 32-bit and 64-bit registry views.
239
SetRegView 32
240
ReadRegStr $1 HKLM ${MaintUninstallKey} "UninstallString"
241
SetRegView lastused
242
243
${If} ${RunningX64}
244
${OrIf} ${IsNativeARM64}
245
${If} $1 == ""
246
SetRegView 64
247
ReadRegStr $1 HKLM ${MaintUninstallKey} "UninstallString"
248
SetRegView lastused
249
${EndIf}
250
${EndIf}
251
252
; If the uninstall string does not exist, skip executing it
253
${If} $1 != ""
254
; $1 is already a quoted string pointing to the install path
255
; so we're already protected against paths with spaces
256
nsExec::Exec "$1 /S"
257
${EndIf}
258
${EndIf}
259
260
; Restore the old value of $1 and $0
261
Pop $1
262
Pop $0
263
FunctionEnd
264
265
################################################################################
266
# Install Sections
267
; Empty section required for the installer to compile as an uninstaller
268
Section ""
269
SectionEnd
270
271
################################################################################
272
# Uninstall Sections
273
274
Section "Uninstall"
275
SetDetailsPrint textonly
276
DetailPrint $(STATUS_UNINSTALL_MAIN)
277
SetDetailsPrint none
278
279
; Delete the app exe to prevent launching the app while we are uninstalling.
280
ClearErrors
281
${DeleteFile} "$INSTDIR\${FileMainEXE}"
282
${If} ${Errors}
283
; If the user closed the application it can take several seconds for it to
284
; shut down completely. If the application is being used by another user we
285
; can still delete the files when the system is restarted.
286
Sleep 5000
287
${DeleteFile} "$INSTDIR\${FileMainEXE}"
288
ClearErrors
289
${EndIf}
290
291
; setup the application model id registration value
292
${un.InitHashAppModelId} "$INSTDIR" "Software\Mozilla\${AppName}\TaskBarIDs"
293
294
SetShellVarContext current ; Set SHCTX to HKCU
295
${un.RegCleanMain} "Software\Mozilla"
296
${un.RegCleanPrefs} "Software\Mozilla\${AppName}"
297
${un.RegCleanUninstall}
298
${un.DeleteShortcuts}
299
300
; Unregister resources associated with Win7 taskbar jump lists.
301
${If} ${AtLeastWin7}
302
${AndIf} "$AppUserModelID" != ""
303
ApplicationID::UninstallJumpLists "$AppUserModelID"
304
${EndIf}
305
306
; Remove the updates directory
307
${un.CleanUpdateDirectories} "Mozilla\Firefox" "Mozilla\updates"
308
309
; Remove any app model id's stored in the registry for this install path
310
DeleteRegValue HKCU "Software\Mozilla\${AppName}\TaskBarIDs" "$INSTDIR"
311
DeleteRegValue HKLM "Software\Mozilla\${AppName}\TaskBarIDs" "$INSTDIR"
312
313
ClearErrors
314
WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
315
${If} ${Errors}
316
StrCpy $TmpVal "HKCU" ; used primarily for logging
317
${Else}
318
SetShellVarContext all ; Set SHCTX to HKLM
319
DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
320
StrCpy $TmpVal "HKLM" ; used primarily for logging
321
${un.RegCleanMain} "Software\Mozilla"
322
${un.RegCleanUninstall}
323
${un.DeleteShortcuts}
324
${un.SetAppLSPCategories}
325
${EndIf}
326
327
${un.RegCleanAppHandler} "FirefoxURL-$AppUserModelID"
328
${un.RegCleanAppHandler} "FirefoxHTML-$AppUserModelID"
329
${un.RegCleanProtocolHandler} "ftp"
330
${un.RegCleanProtocolHandler} "http"
331
${un.RegCleanProtocolHandler} "https"
332
${un.RegCleanProtocolHandler} "mailto"
333
${un.RegCleanFileHandler} ".htm" "FirefoxHTML-$AppUserModelID"
334
${un.RegCleanFileHandler} ".html" "FirefoxHTML-$AppUserModelID"
335
${un.RegCleanFileHandler} ".shtml" "FirefoxHTML-$AppUserModelID"
336
${un.RegCleanFileHandler} ".xht" "FirefoxHTML-$AppUserModelID"
337
${un.RegCleanFileHandler} ".xhtml" "FirefoxHTML-$AppUserModelID"
338
${un.RegCleanFileHandler} ".oga" "FirefoxHTML-$AppUserModelID"
339
${un.RegCleanFileHandler} ".ogg" "FirefoxHTML-$AppUserModelID"
340
${un.RegCleanFileHandler} ".ogv" "FirefoxHTML-$AppUserModelID"
341
${un.RegCleanFileHandler} ".pdf" "FirefoxHTML-$AppUserModelID"
342
${un.RegCleanFileHandler} ".webm" "FirefoxHTML-$AppUserModelID"
343
${un.RegCleanFileHandler} ".svg" "FirefoxHTML-$AppUserModelID"
344
${un.RegCleanFileHandler} ".webp" "FirefoxHTML-$AppUserModelID"
345
346
SetShellVarContext all ; Set SHCTX to HKLM
347
${un.GetSecondInstallPath} "Software\Mozilla" $R9
348
${If} $R9 == "false"
349
SetShellVarContext current ; Set SHCTX to HKCU
350
${un.GetSecondInstallPath} "Software\Mozilla" $R9
351
${EndIf}
352
353
DeleteRegKey HKLM "Software\Clients\StartMenuInternet\${AppRegName}-$AppUserModelID"
354
DeleteRegValue HKLM "Software\RegisteredApplications" "${AppRegName}-$AppUserModelID"
355
356
DeleteRegKey HKCU "Software\Clients\StartMenuInternet\${AppRegName}-$AppUserModelID"
357
DeleteRegValue HKCU "Software\RegisteredApplications" "${AppRegName}-$AppUserModelID"
358
359
; Remove old protocol handler and StartMenuInternet keys without install path
360
; hashes, but only if they're for this installation.
361
ReadRegStr $0 HKLM "Software\Classes\FirefoxHTML\DefaultIcon" ""
362
StrCpy $0 $0 -2
363
${If} $0 == "$INSTDIR\${FileMainEXE}"
364
DeleteRegKey HKLM "Software\Classes\FirefoxHTML"
365
DeleteRegKey HKLM "Software\Classes\FirefoxURL"
366
${StrFilter} "${FileMainEXE}" "+" "" "" $R9
367
DeleteRegKey HKLM "Software\Clients\StartMenuInternet\$R9"
368
DeleteRegValue HKLM "Software\RegisteredApplications" "$R9"
369
DeleteRegValue HKLM "Software\RegisteredApplications" "${AppRegName}"
370
${EndIf}
371
ReadRegStr $0 HKCU "Software\Classes\FirefoxHTML\DefaultIcon" ""
372
StrCpy $0 $0 -2
373
${If} $0 == "$INSTDIR\${FileMainEXE}"
374
DeleteRegKey HKCU "Software\Classes\FirefoxHTML"
375
DeleteRegKey HKCU "Software\Classes\FirefoxURL"
376
${StrFilter} "${FileMainEXE}" "+" "" "" $R9
377
DeleteRegKey HKCU "Software\Clients\StartMenuInternet\$R9"
378
DeleteRegValue HKCU "Software\RegisteredApplications" "$R9"
379
DeleteRegValue HKCU "Software\RegisteredApplications" "${AppRegName}"
380
${EndIf}
381
382
StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\App Paths\${FileMainEXE}"
383
${If} $R9 == "false"
384
DeleteRegKey HKLM "$0"
385
DeleteRegKey HKCU "$0"
386
StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\${FileMainEXE}"
387
DeleteRegKey HKLM "$0"
388
DeleteRegKey HKCU "$0"
389
StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\plugin-container.exe"
390
DeleteRegKey HKLM "$0"
391
DeleteRegKey HKCU "$0"
392
StrCpy $0 "Software\Classes\MIME\Database\Content Type\application/x-xpinstall;app=firefox"
393
DeleteRegKey HKLM "$0"
394
DeleteRegKey HKCU "$0"
395
${Else}
396
ReadRegStr $R1 HKLM "$0" ""
397
${un.RemoveQuotesFromPath} "$R1" $R1
398
${un.GetParent} "$R1" $R1
399
${If} "$INSTDIR" == "$R1"
400
WriteRegStr HKLM "$0" "" "$R9"
401
${un.GetParent} "$R9" $R1
402
WriteRegStr HKLM "$0" "Path" "$R1"
403
${EndIf}
404
${EndIf}
405
406
; Remove our HKCR/Applications key, if it's for this installation.
407
ReadRegStr $0 HKLM "Software\Classes\Applications\${FileMainEXE}\DefaultIcon" ""
408
StrCpy $0 $0 -2
409
${If} $0 == "$INSTDIR\${FileMainEXE}"
410
DeleteRegKey HKLM "Software\Classes\Applications\${FileMainEXE}"
411
${EndIf}
412
ReadRegStr $0 HKCU "Software\Classes\Applications\${FileMainEXE}\DefaultIcon" ""
413
StrCpy $0 $0 -2
414
${If} $0 == "$INSTDIR\${FileMainEXE}"
415
DeleteRegKey HKCU "Software\Classes\Applications\${FileMainEXE}"
416
${EndIf}
417
418
; Remove directories and files we always control before parsing the uninstall
419
; log so empty directories can be removed.
420
${If} ${FileExists} "$INSTDIR\updates"
421
RmDir /r /REBOOTOK "$INSTDIR\updates"
422
${EndIf}
423
${If} ${FileExists} "$INSTDIR\updated"
424
RmDir /r /REBOOTOK "$INSTDIR\updated"
425
${EndIf}
426
${If} ${FileExists} "$INSTDIR\defaults\shortcuts"
427
RmDir /r /REBOOTOK "$INSTDIR\defaults\shortcuts"
428
${EndIf}
429
${If} ${FileExists} "$INSTDIR\distribution"
430
RmDir /r /REBOOTOK "$INSTDIR\distribution"
431
${EndIf}
432
433
; Remove files that may be left behind by the application in the
434
; VirtualStore directory.
435
${un.CleanVirtualStore}
436
437
; Only unregister the dll if the registration points to this installation
438
ReadRegStr $R1 HKCR "CLSID\{0D68D6D0-D93D-4D08-A30D-F00DD1F45B24}\InProcServer32" ""
439
${If} "$INSTDIR\AccessibleMarshal.dll" == "$R1"
440
${UnregisterDLL} "$INSTDIR\AccessibleMarshal.dll"
441
${EndIf}
442
443
; Only unregister the dll if the registration points to this installation
444
ReadRegStr $R1 HKCR "CLSID\${AccessibleHandlerCLSID}\InprocHandler32" ""
445
${If} "$INSTDIR\AccessibleHandler.dll" == "$R1"
446
${UnregisterDLL} "$INSTDIR\AccessibleHandler.dll"
447
${EndIf}
448
449
!ifdef MOZ_LAUNCHER_PROCESS
450
DeleteRegValue HKCU ${MOZ_LAUNCHER_SUBKEY} "$INSTDIR\${FileMainEXE}|Launcher"
451
DeleteRegValue HKCU ${MOZ_LAUNCHER_SUBKEY} "$INSTDIR\${FileMainEXE}|Browser"
452
DeleteRegValue HKCU ${MOZ_LAUNCHER_SUBKEY} "$INSTDIR\${FileMainEXE}|Image"
453
DeleteRegValue HKCU ${MOZ_LAUNCHER_SUBKEY} "$INSTDIR\${FileMainEXE}|Telemetry"
454
!endif
455
456
!ifdef MOZ_UPDATE_AGENT
457
; Unregister the update agent
458
nsExec::Exec '"$INSTDIR\updateagent.exe" unregister-task "${UpdateAgentFullName} $AppUserModelID"'
459
!endif
460
461
; Uninstall the default browser agent scheduled task.
462
; This also removes the registry entries it creates.
463
Exec '"$INSTDIR\default-browser-agent.exe" unregister-task $AppUserModelID'
464
465
${un.RemovePrecompleteEntries} "false"
466
467
${If} ${FileExists} "$INSTDIR\defaults\pref\channel-prefs.js"
468
Delete /REBOOTOK "$INSTDIR\defaults\pref\channel-prefs.js"
469
${EndIf}
470
RmDir "$INSTDIR\defaults\pref"
471
RmDir "$INSTDIR\defaults"
472
${If} ${FileExists} "$INSTDIR\uninstall"
473
; Remove the uninstall directory that we control
474
RmDir /r /REBOOTOK "$INSTDIR\uninstall"
475
${EndIf}
476
${If} ${FileExists} "$INSTDIR\install.log"
477
Delete /REBOOTOK "$INSTDIR\install.log"
478
${EndIf}
479
${If} ${FileExists} "$INSTDIR\update-settings.ini"
480
Delete /REBOOTOK "$INSTDIR\update-settings.ini"
481
${EndIf}
482
483
; Explicitly remove empty webapprt dir in case it exists (bug 757978).
484
RmDir "$INSTDIR\webapprt\components"
485
RmDir "$INSTDIR\webapprt"
486
487
; Remove the installation directory if it is empty
488
RmDir "$INSTDIR"
489
490
; If firefox.exe was successfully deleted yet we still need to restart to
491
; remove other files create a dummy firefox.exe.moz-delete to prevent the
492
; installer from allowing an install without restart when it is required
493
; to complete an uninstall.
494
${If} ${RebootFlag}
495
; Admin is required to delete files on reboot so only add the moz-delete if
496
; the user is an admin. After calling UAC::IsAdmin $0 will equal 1 if the
497
; user is an admin.
498
UAC::IsAdmin
499
${If} "$0" == "1"
500
${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-delete"
501
FileOpen $0 "$INSTDIR\${FileMainEXE}.moz-delete" w
502
FileWrite $0 "Will be deleted on restart"
503
Delete /REBOOTOK "$INSTDIR\${FileMainEXE}.moz-delete"
504
FileClose $0
505
${EndUnless}
506
${EndIf}
507
${EndIf}
508
509
; Refresh desktop icons otherwise the start menu internet item won't be
510
; removed and other ugly things will happen like recreation of the app's
511
; clients registry key by the OS under some conditions.
512
${RefreshShellIcons}
513
514
; Users who uninstall then reinstall expecting Firefox to use a clean profile
515
; may be surprised during first-run. This key is checked during startup of Firefox and
516
; subsequently deleted after checking. If the value is found during startup
517
; the browser will offer to Reset Firefox. We use the UpdateChannel to match
518
; uninstalls of Firefox-release with reinstalls of Firefox-release, for example.
519
WriteRegStr HKCU "Software\Mozilla\Firefox" "Uninstalled-${UpdateChannel}" "True"
520
521
!ifdef MOZ_MAINTENANCE_SERVICE
522
; Get the path the allowed cert is at and remove it
523
; Keep this block of code last since it modfies the reg view
524
ServicesHelper::PathToUniqueRegistryPath "$INSTDIR"
525
Pop $MaintCertKey
526
${If} $MaintCertKey != ""
527
; Always use the 64bit registry for certs on 64bit systems.
528
${If} ${RunningX64}
529
${OrIf} ${IsNativeARM64}
530
SetRegView 64
531
${EndIf}
532
DeleteRegKey HKLM "$MaintCertKey"
533
${If} ${RunningX64}
534
${OrIf} ${IsNativeARM64}
535
SetRegView lastused
536
${EndIf}
537
${EndIf}
538
Call un.UninstallServiceIfNotUsed
539
!endif
540
541
!ifdef MOZ_BITS_DOWNLOAD
542
BitsUtils::CancelBitsJobsByName "MozillaUpdate $AppUserModelID"
543
Pop $0
544
!endif
545
546
${un.IsFirewallSvcRunning}
547
Pop $0
548
${If} "$0" == "true"
549
liteFirewallW::RemoveRule "$INSTDIR\${FileMainEXE}" "${BrandShortName} ($INSTDIR)"
550
${EndIf}
551
SectionEnd
552
553
################################################################################
554
# Language
555
556
!insertmacro MOZ_MUI_LANGUAGE 'baseLocale'
557
!verbose push
558
!verbose 3
559
!include "overrideLocale.nsh"
560
!include "customLocale.nsh"
561
!verbose pop
562
563
; Set this after the locale files to override it if it is in the locale. Using
564
; " " for BrandingText will hide the "Nullsoft Install System..." branding.
565
BrandingText " "
566
567
################################################################################
568
# Page pre, show, and leave functions
569
570
Function un.preWelcome
571
${If} ${FileExists} "$INSTDIR\distribution\modern-wizard.bmp"
572
Delete "$PLUGINSDIR\modern-wizard.bmp"
573
CopyFiles /SILENT "$INSTDIR\distribution\modern-wizard.bmp" "$PLUGINSDIR\modern-wizard.bmp"
574
${EndIf}
575
!ifdef MOZ_BITS_DOWNLOAD
576
BitsUtils::StartBitsServiceBackground
577
!endif
578
579
; We don't want the header bitmap showing on the welcome page.
580
GetDlgItem $0 $HWNDPARENT 1046
581
ShowWindow $0 ${SW_HIDE}
582
FunctionEnd
583
584
Function un.ShowWelcome
585
; The welcome and finish pages don't get the correct colors for their labels
586
; like the other pages do, presumably because they're built by filling in an
587
; InstallOptions .ini file instead of from a dialog resource like the others.
588
; Field 2 is the header and Field 3 is the body text.
589
ReadINIStr $0 "$PLUGINSDIR\ioSpecial.ini" "Field 2" "HWND"
590
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
591
592
ReadINIStr $0 "$PLUGINSDIR\ioSpecial.ini" "Field 3" "HWND"
593
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
594
595
; We need to overwrite the sidebar image so that we get it drawn with proper
596
; scaling if the display is scaled at anything above 100%.
597
${un.ChangeMUISidebarImage} "$PLUGINSDIR\modern-wizard.bmp"
598
FunctionEnd
599
600
Function un.leaveWelcome
601
${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
602
Banner::show /NOUNLOAD "$(BANNER_CHECK_EXISTING)"
603
604
; If we already found a window once and we're checking again, wait for an
605
; additional five seconds for the app to close.
606
${If} "$TmpVal" == "FoundAppWindow"
607
Sleep 5000
608
${EndIf}
609
610
${PushFilesToCheck}
611
612
${un.CheckForFilesInUse} $TmpVal
613
614
Banner::destroy
615
616
; If there are files in use $TmpVal will be "true"
617
${If} "$TmpVal" == "true"
618
; If it finds a window of the right class, then ManualCloseAppPrompt will
619
; abort leaving the value of $TmpVal set to "FoundAppWindow".
620
StrCpy $TmpVal "FoundAppWindow"
621
${un.ManualCloseAppPrompt} "${MainWindowClass}" "$(WARN_MANUALLY_CLOSE_APP_UNINSTALL)"
622
${un.ManualCloseAppPrompt} "${DialogWindowClass}" "$(WARN_MANUALLY_CLOSE_APP_UNINSTALL)"
623
; If the message window is not found set $TmpVal to "true" so the restart
624
; required message is displayed.
625
StrCpy $TmpVal "true"
626
${EndIf}
627
${EndIf}
628
629
; Bring back the header bitmap for the next pages.
630
GetDlgItem $0 $HWNDPARENT 1046
631
ShowWindow $0 ${SW_SHOW}
632
FunctionEnd
633
634
Function un.preConfirm
635
; The header and subheader on the wizard pages don't get the correct text
636
; color by default for some reason, even though the other controls do.
637
GetDlgItem $0 $HWNDPARENT 1037
638
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
639
GetDlgItem $0 $HWNDPARENT 1038
640
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
641
642
${If} ${FileExists} "$INSTDIR\distribution\modern-header.bmp"
643
Delete "$PLUGINSDIR\modern-header.bmp"
644
CopyFiles /SILENT "$INSTDIR\distribution\modern-header.bmp" "$PLUGINSDIR\modern-header.bmp"
645
${EndIf}
646
${un.ChangeMUIHeaderImage} "$PLUGINSDIR\modern-header.bmp"
647
648
; Setup the unconfirm.ini file for the Custom Uninstall Confirm Page
649
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Settings" NumFields "3"
650
651
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Type "label"
652
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Text "$(UN_CONFIRM_UNINSTALLED_FROM)"
653
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Left "0"
654
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Right "-1"
655
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Top "5"
656
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Bottom "15"
657
658
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Type "text"
659
; The contents of this control must be set as follows in the pre function
660
; ${MUI_INSTALLOPTIONS_READ} $1 "unconfirm.ini" "Field 2" "HWND"
661
; SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
662
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" State ""
663
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Left "0"
664
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Right "-1"
665
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Top "17"
666
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Bottom "30"
667
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" flags "READONLY"
668
669
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Type "label"
670
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Text "$(UN_CONFIRM_CLICK)"
671
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Left "0"
672
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Right "-1"
673
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Top "130"
674
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Bottom "150"
675
676
${If} "$TmpVal" == "true"
677
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Type "label"
678
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Text "$(SUMMARY_REBOOT_REQUIRED_UNINSTALL)"
679
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Left "0"
680
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Right "-1"
681
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Top "35"
682
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Bottom "45"
683
684
WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Settings" NumFields "4"
685
${EndIf}
686
687
!insertmacro MUI_HEADER_TEXT "$(UN_CONFIRM_PAGE_TITLE)" "$(UN_CONFIRM_PAGE_SUBTITLE)"
688
; The Summary custom page has a textbox that will automatically receive
689
; focus. This sets the focus to the Install button instead.
690
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "unconfirm.ini"
691
GetDlgItem $0 $HWNDPARENT 1
692
System::Call "user32::SetFocus(i r0, i 0x0007, i,i)i"
693
${MUI_INSTALLOPTIONS_READ} $1 "unconfirm.ini" "Field 2" "HWND"
694
SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
695
!insertmacro MUI_INSTALLOPTIONS_SHOW
696
FunctionEnd
697
698
Function un.preFinish
699
; Need to give the survey (readme) checkbox a few extra DU's of height
700
; to accommodate a potentially multi-line label. If the reboot flag is set,
701
; then we're not showing the survey checkbox and Field 4 is the "reboot now"
702
; radio button; setting it to go from 90 to 120 (instead of 90 to 100) would
703
; cover up Field 5 which is "reboot later", running from 110 to 120. For
704
; whatever reason child windows get created at the bottom of the z-order, so
705
; 4 overlaps 5.
706
${IfNot} ${RebootFlag}
707
WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Field 4" Bottom "120"
708
${EndIf}
709
710
; We don't want the header bitmap showing on the finish page.
711
GetDlgItem $0 $HWNDPARENT 1046
712
ShowWindow $0 ${SW_HIDE}
713
FunctionEnd
714
715
Function un.ShowFinish
716
ReadINIStr $0 "$PLUGINSDIR\ioSpecial.ini" "Field 2" "HWND"
717
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
718
719
ReadINIStr $0 "$PLUGINSDIR\ioSpecial.ini" "Field 3" "HWND"
720
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
721
722
; We need to overwrite the sidebar image so that we get it drawn with proper
723
; scaling if the display is scaled at anything above 100%.
724
${un.ChangeMUISidebarImage} "$PLUGINSDIR\modern-wizard.bmp"
725
726
; Either Fields 4 and 5 are the reboot option radio buttons, or Field 4 is
727
; the survey checkbox and Field 5 doesn't exist. Either way, we need to
728
; clear the theme from them before we can set their background colors.
729
ReadINIStr $0 "$PLUGINSDIR\ioSpecial.ini" "Field 4" "HWND"
730
System::Call 'uxtheme::SetWindowTheme(i $0, w " ", w " ")'
731
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
732
733
ClearErrors
734
ReadINIStr $0 "$PLUGINSDIR\ioSpecial.ini" "Field 5" "HWND"
735
${IfNot} ${Errors}
736
System::Call 'uxtheme::SetWindowTheme(i $0, w " ", w " ")'
737
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
738
${EndIf}
739
FunctionEnd
740
741
################################################################################
742
# Initialization Functions
743
744
Function .onInit
745
; Remove the current exe directory from the search order.
746
; This only effects LoadLibrary calls and not implicitly loaded DLLs.
747
System::Call 'kernel32::SetDllDirectoryW(w "")'
748
749
; We need this set up for most of the helper.exe operations.
750
${UninstallOnInitCommon}
751
FunctionEnd
752
753
Function un.onInit
754
; Remove the current exe directory from the search order.
755
; This only effects LoadLibrary calls and not implicitly loaded DLLs.
756
System::Call 'kernel32::SetDllDirectoryW(w "")'
757
758
StrCpy $LANGUAGE 0
759
StrCpy $ShouldOpenSurvey "0"
760
761
${un.UninstallUnOnInitCommon}
762
763
!insertmacro InitInstallOptionsFile "unconfirm.ini"
764
FunctionEnd
765
766
Function .onGUIEnd
767
${OnEndCommon}
768
FunctionEnd
769
770
Function un.onGUIEnd
771
${un.OnEndCommon}
772
773
${If} $ShouldOpenSurvey == "1"
774
; Though these values are sometimes incorrect due to bug 444664 it happens
775
; so rarely it isn't worth working around it by reading the registry values.
776
${WinVerGetMajor} $0
777
${WinVerGetMinor} $1
778
${WinVerGetBuild} $2
779
${WinVerGetServicePackLevel} $3
780
StrCpy $R1 "${URLUninstallSurvey}$0.$1.$2.$3"
781
782
; We can't just open the URL normally because we are most likely running
783
; elevated without an unelevated process to redirect through, and we're
784
; not going to go around starting elevated web browsers. But to start an
785
; unelevated process directly from here we need a pretty nasty hack; see
786
; the ExecInExplorer plugin code itself for the details.
787
; If we were the default browser and we've now been uninstalled, we need
788
; to take steps to make sure the user doesn't see an "open with" dialog;
789
; they're helping us out by answering this survey, they don't need more
790
; friction. Sometimes Windows 7 and 8 automatically switch the default to
791
; IE, but it isn't reliable, so we'll manually invoke IE in that case.
792
; Windows 10 always seems to just clear the default browser, so for it
793
; we'll manually invoke Edge using Edge's custom URI scheme.
794
${If} ${AtLeastWin10}
795
ExecInExplorer::Exec "microsoft-edge:$R1"
796
${Else}
797
ExecInExplorer::Exec "iexplore.exe" /cmdargs "$R1"
798
${EndIf}
799
${EndIf}
800
FunctionEnd