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
!macro PostUpdate
6
; PostUpdate is called from both session 0 and from the user session
7
; for service updates, make sure that we only register with the user session
8
; Otherwise ApplicationID::Set can fail intermittently with a file in use error.
9
System::Call "kernel32::GetCurrentProcessId() i.r0"
10
System::Call "kernel32::ProcessIdToSessionId(i $0, *i ${NSIS_MAX_STRLEN} r9)"
11
12
; Determine if we're the protected UserChoice default or not. If so fix the
13
; start menu tile. In case there are 2 Firefox installations, we only do
14
; this if the application being updated is the default.
15
ReadRegStr $0 HKCU "Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice" "ProgId"
16
${WordFind} "$0" "-" "+1{" $0
17
${If} $0 == "FirefoxURL"
18
${AndIf} $9 != 0 ; We're not running in session 0
19
ReadRegStr $0 HKCU "Software\Classes\FirefoxURL\shell\open\command" ""
20
${GetPathFromString} "$0" $0
21
${GetParent} "$0" $0
22
${If} ${FileExists} "$0"
23
${GetLongPath} "$0" $0
24
${EndIf}
25
${EndIf}
26
27
${CreateShortcutsLog}
28
29
; Remove registry entries for non-existent apps and for apps that point to our
30
; install location in the Software\Mozilla key and uninstall registry entries
31
; that point to our install location for both HKCU and HKLM.
32
SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
33
${RegCleanMain} "Software\Mozilla"
34
${RegCleanUninstall}
35
${UpdateProtocolHandlers}
36
37
; setup the application model id registration value
38
${InitHashAppModelId} "$INSTDIR" "Software\Mozilla\${AppName}\TaskBarIDs"
39
40
ClearErrors
41
WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
42
${If} ${Errors}
43
StrCpy $TmpVal "HKCU"
44
${Else}
45
SetShellVarContext all ; Set SHCTX to all users (e.g. HKLM)
46
DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
47
StrCpy $TmpVal "HKLM"
48
${RegCleanMain} "Software\Mozilla"
49
${RegCleanUninstall}
50
${UpdateProtocolHandlers}
51
${FixShellIconHandler} "HKLM"
52
${SetAppLSPCategories} ${LSP_CATEGORIES}
53
54
; Add the Firewall entries after an update
55
Call AddFirewallEntries
56
57
ReadRegStr $0 HKLM "Software\mozilla.org\Mozilla" "CurrentVersion"
58
${If} "$0" != "${GREVersion}"
59
WriteRegStr HKLM "Software\mozilla.org\Mozilla" "CurrentVersion" "${GREVersion}"
60
${EndIf}
61
${EndIf}
62
63
; Adds a pinned Task Bar shortcut (see MigrateTaskBarShortcut for details).
64
${MigrateTaskBarShortcut}
65
66
; Update the name/icon/AppModelID of our shortcuts as needed, then update the
67
; lastwritetime of the Start Menu shortcut to clear the tile icon cache.
68
; Do this for both shell contexts in case the user has shortcuts in multiple
69
; locations, then restore the previous context at the end.
70
SetShellVarContext all
71
${UpdateShortcutsBranding}
72
${If} ${AtLeastWin8}
73
${TouchStartMenuShortcut}
74
${EndIf}
75
Call FixShortcutAppModelIDs
76
SetShellVarContext current
77
${UpdateShortcutsBranding}
78
${If} ${AtLeastWin8}
79
${TouchStartMenuShortcut}
80
${EndIf}
81
Call FixShortcutAppModelIDs
82
${If} $TmpVal == "HKLM"
83
SetShellVarContext all
84
${ElseIf} $TmpVal == "HKCU"
85
SetShellVarContext current
86
${EndIf}
87
88
${RemoveDeprecatedKeys}
89
${Set32to64DidMigrateReg}
90
91
${SetAppKeys}
92
${FixClassKeys}
93
${SetUninstallKeys}
94
${If} $TmpVal == "HKLM"
95
${SetStartMenuInternet} HKLM
96
${ElseIf} $TmpVal == "HKCU"
97
${SetStartMenuInternet} HKCU
98
${EndIf}
99
100
; Remove files that may be left behind by the application in the
101
; VirtualStore directory.
102
${CleanVirtualStore}
103
104
${RemoveDeprecatedFiles}
105
106
; Fix the distribution.ini file if applicable
107
${FixDistributionsINI}
108
109
RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
110
111
; Register AccessibleHandler.dll with COM (this requires write access to HKLM)
112
${RegisterAccessibleHandler}
113
114
; Register AccessibleMarshal.dll with COM (this requires write access to HKLM)
115
${RegisterAccessibleMarshal}
116
117
!ifdef MOZ_MAINTENANCE_SERVICE
118
Call IsUserAdmin
119
Pop $R0
120
${If} $R0 == "true"
121
; Only proceed if we have HKLM write access
122
${AndIf} $TmpVal == "HKLM"
123
; We check to see if the maintenance service install was already attempted.
124
; Since the Maintenance service can be installed either x86 or x64,
125
; always use the 64-bit registry for checking if an attempt was made.
126
${If} ${RunningX64}
127
${OrIf} ${IsNativeARM64}
128
SetRegView 64
129
${EndIf}
130
ReadRegDWORD $5 HKLM "Software\Mozilla\MaintenanceService" "Attempted"
131
ClearErrors
132
${If} ${RunningX64}
133
${OrIf} ${IsNativeARM64}
134
SetRegView lastused
135
${EndIf}
136
137
; Add the registry keys for allowed certificates.
138
${AddMaintCertKeys}
139
140
; If the maintenance service is already installed, do nothing.
141
; The maintenance service will launch:
142
; maintenanceservice_installer.exe /Upgrade to upgrade the maintenance
143
; service if necessary. If the update was done from updater.exe without
144
; the service (i.e. service is failing), updater.exe will do the update of
145
; the service. The reasons we do not do it here is because we don't want
146
; to have to prompt for limited user accounts when the service isn't used
147
; and we currently call the PostUpdate twice, once for the user and once
148
; for the SYSTEM account. Also, this would stop the maintenance service
149
; and we need a return result back to the service when run that way.
150
${If} $5 == ""
151
; An install of maintenance service was never attempted.
152
; We know we are an Admin and that we have write access into HKLM
153
; based on the above checks, so attempt to just run the EXE.
154
; In the worst case, in case there is some edge case with the
155
; IsAdmin check and the permissions check, the maintenance service
156
; will just fail to be attempted to be installed.
157
nsExec::Exec "$\"$INSTDIR\maintenanceservice_installer.exe$\""
158
${EndIf}
159
${EndIf}
160
!endif
161
162
!ifdef MOZ_UPDATE_AGENT
163
; This macro runs the update agent with the update-task-local-service
164
; command, if it detects the needed admin privileges. Otherwise it
165
; runs with update-task.
166
; Both commands attempt to remove the scheduled task, then register
167
; a new one. If the task was registered by an elevated user, it won't
168
; be removable when not elevated, so the unelevated attempt will fail
169
; harmlessly.
170
; Therefore it is safe to run this in both elevated and nonelevated
171
; PostUpdate: The highest privileged run will win out, so the task can
172
; run as Local Service if it was ever possible to register it that way.
173
${PushRegisterUpdateAgentTaskCommand} "update"
174
Pop $0
175
${If} "$0" != ""
176
nsExec::Exec $0
177
Pop $0
178
${EndIf}
179
!endif
180
181
!ifdef MOZ_LAUNCHER_PROCESS
182
${ResetLauncherProcessDefaults}
183
!endif
184
185
; Make sure the scheduled task registration for the default browser agent gets
186
; updated, but only if we're not the instance of PostUpdate that was started
187
; by the service, because this needs to run as the actual user. Also, don't do
188
; that if the installer was told not to register the agent task at all.
189
!ifdef MOZ_DEFAULT_BROWSER_AGENT
190
${If} $TmpVal == "HKCU"
191
ClearErrors
192
ReadRegDWORD $0 HKCU "Software\Mozilla\${AppName}\Installer\$AppUserModelID" \
193
"DidRegisterDefaultBrowserAgent"
194
${If} $0 != 0
195
${OrIf} ${Errors}
196
Exec '"$INSTDIR\default-browser-agent.exe" update-task $AppUserModelID'
197
${EndIf}
198
${EndIf}
199
!endif
200
201
!macroend
202
!define PostUpdate "!insertmacro PostUpdate"
203
204
; Update the last modified time on the Start Menu shortcut, so that its icon
205
; gets refreshed. Should be called on Win8+ after UpdateShortcutBranding.
206
!macro TouchStartMenuShortcut
207
${If} ${FileExists} "$SMPROGRAMS\${BrandShortName}.lnk"
208
FileOpen $0 "$SMPROGRAMS\${BrandShortName}.lnk" a
209
${IfNot} ${Errors}
210
System::Call '*(i, i) p .r1'
211
System::Call 'kernel32::GetSystemTimeAsFileTime(p r1)'
212
System::Call 'kernel32::SetFileTime(p r0, i 0, i 0, p r1) i .r2'
213
System::Free $1
214
FileClose $0
215
${EndIf}
216
${EndIf}
217
!macroend
218
!define TouchStartMenuShortcut "!insertmacro TouchStartMenuShortcut"
219
220
!macro SetAsDefaultAppGlobal
221
${RemoveDeprecatedKeys} ; Does not use SHCTX
222
223
SetShellVarContext all ; Set SHCTX to all users (e.g. HKLM)
224
${SetHandlers} ; Uses SHCTX
225
${SetStartMenuInternet} "HKLM"
226
${FixShellIconHandler} "HKLM"
227
${ShowShortcuts}
228
!macroend
229
!define SetAsDefaultAppGlobal "!insertmacro SetAsDefaultAppGlobal"
230
231
; Removes shortcuts for this installation. This should also remove the
232
; application from Open With for the file types the application handles
233
; (bug 370480).
234
!macro HideShortcuts
235
; Find the correct registry path to clear IconsVisible.
236
StrCpy $R1 "Software\Clients\StartMenuInternet\${AppRegName}-$AppUserModelID\InstallInfo"
237
ReadRegDWORD $0 HKLM "$R1" "ShowIconsCommand"
238
${If} ${Errors}
239
${StrFilter} "${FileMainEXE}" "+" "" "" $0
240
StrCpy $R1 "Software\Clients\StartMenuInternet\$0\InstallInfo"
241
${EndIf}
242
WriteRegDWORD HKLM "$R1" "IconsVisible" 0
243
${If} ${AtLeastWin8}
244
WriteRegDWORD HKCU "$R1" "IconsVisible" 0
245
${EndIf}
246
247
SetShellVarContext all ; Set $DESKTOP to All Users
248
${Unless} ${FileExists} "$DESKTOP\${BrandShortName}.lnk"
249
SetShellVarContext current ; Set $DESKTOP to the current user's desktop
250
${EndUnless}
251
252
${If} ${FileExists} "$DESKTOP\${BrandShortName}.lnk"
253
ShellLink::GetShortCutArgs "$DESKTOP\${BrandShortName}.lnk"
254
Pop $0
255
${If} "$0" == ""
256
ShellLink::GetShortCutTarget "$DESKTOP\${BrandShortName}.lnk"
257
Pop $0
258
${GetLongPath} "$0" $0
259
${If} "$0" == "$INSTDIR\${FileMainEXE}"
260
Delete "$DESKTOP\${BrandShortName}.lnk"
261
${EndIf}
262
${EndIf}
263
${EndIf}
264
265
SetShellVarContext all ; Set $SMPROGRAMS to All Users
266
${Unless} ${FileExists} "$SMPROGRAMS\${BrandShortName}.lnk"
267
SetShellVarContext current ; Set $SMPROGRAMS to the current user's Start
268
; Menu Programs directory
269
${EndUnless}
270
271
${If} ${FileExists} "$SMPROGRAMS\${BrandShortName}.lnk"
272
ShellLink::GetShortCutArgs "$SMPROGRAMS\${BrandShortName}.lnk"
273
Pop $0
274
${If} "$0" == ""
275
ShellLink::GetShortCutTarget "$SMPROGRAMS\${BrandShortName}.lnk"
276
Pop $0
277
${GetLongPath} "$0" $0
278
${If} "$0" == "$INSTDIR\${FileMainEXE}"
279
Delete "$SMPROGRAMS\${BrandShortName}.lnk"
280
${EndIf}
281
${EndIf}
282
${EndIf}
283
284
${If} ${FileExists} "$QUICKLAUNCH\${BrandShortName}.lnk"
285
ShellLink::GetShortCutArgs "$QUICKLAUNCH\${BrandShortName}.lnk"
286
Pop $0
287
${If} "$0" == ""
288
ShellLink::GetShortCutTarget "$QUICKLAUNCH\${BrandShortName}.lnk"
289
Pop $0
290
${GetLongPath} "$0" $0
291
${If} "$0" == "$INSTDIR\${FileMainEXE}"
292
Delete "$QUICKLAUNCH\${BrandShortName}.lnk"
293
${EndIf}
294
${EndIf}
295
${EndIf}
296
!macroend
297
!define HideShortcuts "!insertmacro HideShortcuts"
298
299
; Adds shortcuts for this installation. This should also add the application
300
; to Open With for the file types the application handles (bug 370480).
301
!macro ShowShortcuts
302
; Find the correct registry path to set IconsVisible.
303
StrCpy $R1 "Software\Clients\StartMenuInternet\${AppRegName}-$AppUserModelID\InstallInfo"
304
ReadRegDWORD $0 HKLM "$R1" "ShowIconsCommand"
305
${If} ${Errors}
306
${StrFilter} "${FileMainEXE}" "+" "" "" $0
307
StrCpy $R1 "Software\Clients\StartMenuInternet\$0\InstallInfo"
308
${EndIf}
309
WriteRegDWORD HKLM "$R1" "IconsVisible" 1
310
${If} ${AtLeastWin8}
311
WriteRegDWORD HKCU "$R1" "IconsVisible" 1
312
${EndIf}
313
314
SetShellVarContext all ; Set $DESKTOP to All Users
315
${Unless} ${FileExists} "$DESKTOP\${BrandShortName}.lnk"
316
CreateShortCut "$DESKTOP\${BrandShortName}.lnk" "$INSTDIR\${FileMainEXE}"
317
${If} ${FileExists} "$DESKTOP\${BrandShortName}.lnk"
318
ShellLink::SetShortCutWorkingDirectory "$DESKTOP\${BrandShortName}.lnk" "$INSTDIR"
319
${If} ${AtLeastWin7}
320
${AndIf} "$AppUserModelID" != ""
321
ApplicationID::Set "$DESKTOP\${BrandShortName}.lnk" "$AppUserModelID" "true"
322
${EndIf}
323
${Else}
324
SetShellVarContext current ; Set $DESKTOP to the current user's desktop
325
${Unless} ${FileExists} "$DESKTOP\${BrandShortName}.lnk"
326
CreateShortCut "$DESKTOP\${BrandShortName}.lnk" "$INSTDIR\${FileMainEXE}"
327
${If} ${FileExists} "$DESKTOP\${BrandShortName}.lnk"
328
ShellLink::SetShortCutWorkingDirectory "$DESKTOP\${BrandShortName}.lnk" \
329
"$INSTDIR"
330
${If} ${AtLeastWin7}
331
${AndIf} "$AppUserModelID" != ""
332
ApplicationID::Set "$DESKTOP\${BrandShortName}.lnk" "$AppUserModelID" "true"
333
${EndIf}
334
${EndIf}
335
${EndUnless}
336
${EndIf}
337
${EndUnless}
338
339
SetShellVarContext all ; Set $SMPROGRAMS to All Users
340
${Unless} ${FileExists} "$SMPROGRAMS\${BrandShortName}.lnk"
341
CreateShortCut "$SMPROGRAMS\${BrandShortName}.lnk" "$INSTDIR\${FileMainEXE}"
342
${If} ${FileExists} "$SMPROGRAMS\${BrandShortName}.lnk"
343
ShellLink::SetShortCutWorkingDirectory "$SMPROGRAMS\${BrandShortName}.lnk" \
344
"$INSTDIR"
345
${If} ${AtLeastWin7}
346
${AndIf} "$AppUserModelID" != ""
347
ApplicationID::Set "$SMPROGRAMS\${BrandShortName}.lnk" "$AppUserModelID" "true"
348
${EndIf}
349
${Else}
350
SetShellVarContext current ; Set $SMPROGRAMS to the current user's Start
351
; Menu Programs directory
352
${Unless} ${FileExists} "$SMPROGRAMS\${BrandShortName}.lnk"
353
CreateShortCut "$SMPROGRAMS\${BrandShortName}.lnk" "$INSTDIR\${FileMainEXE}"
354
${If} ${FileExists} "$SMPROGRAMS\${BrandShortName}.lnk"
355
ShellLink::SetShortCutWorkingDirectory "$SMPROGRAMS\${BrandShortName}.lnk" \
356
"$INSTDIR"
357
${If} ${AtLeastWin7}
358
${AndIf} "$AppUserModelID" != ""
359
ApplicationID::Set "$SMPROGRAMS\${BrandShortName}.lnk" "$AppUserModelID" "true"
360
${EndIf}
361
${EndIf}
362
${EndUnless}
363
${EndIf}
364
${EndUnless}
365
366
; Windows 7 doesn't use the QuickLaunch directory
367
${Unless} ${AtLeastWin7}
368
${AndUnless} ${FileExists} "$QUICKLAUNCH\${BrandShortName}.lnk"
369
CreateShortCut "$QUICKLAUNCH\${BrandShortName}.lnk" \
370
"$INSTDIR\${FileMainEXE}"
371
${If} ${FileExists} "$QUICKLAUNCH\${BrandShortName}.lnk"
372
ShellLink::SetShortCutWorkingDirectory "$QUICKLAUNCH\${BrandShortName}.lnk" \
373
"$INSTDIR"
374
${EndIf}
375
${EndUnless}
376
!macroend
377
!define ShowShortcuts "!insertmacro ShowShortcuts"
378
379
; Update the branding name on all shortcuts our installer created
380
; to convert from BrandFullName (which is what we used to name shortcuts)
381
; to BrandShortName (which is what we now name shortcuts). We only rename
382
; desktop and start menu shortcuts, because touching taskbar pins often
383
; (but inconsistently) triggers various broken behaviors in the shell.
384
; This assumes SHCTX is set correctly.
385
!macro UpdateShortcutsBranding
386
${UpdateOneShortcutBranding} "STARTMENU" "$SMPROGRAMS"
387
${UpdateOneShortcutBranding} "DESKTOP" "$DESKTOP"
388
!macroend
389
!define UpdateShortcutsBranding "!insertmacro UpdateShortcutsBranding"
390
391
!macro UpdateOneShortcutBranding LOG_SECTION SHORTCUT_DIR
392
; Only try to rename the shortcuts found in the shortcuts log, to avoid
393
; blowing away a name that the user created.
394
${GetLongPath} "$INSTDIR\uninstall\${SHORTCUTS_LOG}" $R9
395
${If} ${FileExists} "$R9"
396
ClearErrors
397
; The shortcuts log contains a numbered list of entries for each section,
398
; but we never actually create more than one.
399
ReadINIStr $R8 "$R9" "${LOG_SECTION}" "Shortcut0"
400
${IfNot} ${Errors}
401
${If} ${FileExists} "${SHORTCUT_DIR}\$R8"
402
ShellLink::GetShortCutTarget "${SHORTCUT_DIR}\$R8"
403
Pop $R7
404
${GetLongPath} "$R7" $R7
405
${If} $R7 == "$INSTDIR\${FileMainEXE}"
406
${AndIf} $R8 != "${BrandShortName}.lnk"
407
${AndIfNot} ${FileExists} "${SHORTCUT_DIR}\${BrandShortName}.lnk"
408
ClearErrors
409
Rename "${SHORTCUT_DIR}\$R8" "${SHORTCUT_DIR}\${BrandShortName}.lnk"
410
${IfNot} ${Errors}
411
; Update the shortcut log manually instead of calling LogShortcut
412
; because it would add a Shortcut1 entry, and we really do want to
413
; overwrite the existing entry 0, since we just renamed the file.
414
WriteINIStr "$R9" "${LOG_SECTION}" "Shortcut0" \
415
"${BrandShortName}.lnk"
416
${EndIf}
417
${EndIf}
418
${EndIf}
419
${EndIf}
420
${EndIf}
421
!macroend
422
!define UpdateOneShortcutBranding "!insertmacro UpdateOneShortcutBranding"
423
424
!macro AddAssociationIfNoneExist FILE_TYPE KEY
425
ClearErrors
426
EnumRegKey $7 HKCR "${FILE_TYPE}" 0
427
${If} ${Errors}
428
WriteRegStr SHCTX "SOFTWARE\Classes\${FILE_TYPE}" "" ${KEY}
429
${EndIf}
430
WriteRegStr SHCTX "SOFTWARE\Classes\${FILE_TYPE}\OpenWithProgids" ${KEY} ""
431
!macroend
432
!define AddAssociationIfNoneExist "!insertmacro AddAssociationIfNoneExist"
433
434
; Adds the protocol and file handler registry entries for making Firefox the
435
; default handler (uses SHCTX).
436
!macro SetHandlers
437
${GetLongPath} "$INSTDIR\${FileMainEXE}" $8
438
439
; See if we're using path hash suffixed registry keys for this install.
440
StrCpy $5 ""
441
${StrFilter} "${FileMainEXE}" "+" "" "" $2
442
ReadRegStr $0 SHCTX "Software\Clients\StartMenuInternet\$2\DefaultIcon" ""
443
StrCpy $0 $0 -2
444
${If} $0 != $8
445
StrCpy $5 "-$AppUserModelID"
446
${EndIf}
447
448
StrCpy $0 "SOFTWARE\Classes"
449
StrCpy $2 "$\"$8$\" -osint -url $\"%1$\""
450
451
; Associate the file handlers with FirefoxHTML, if they aren't already.
452
ReadRegStr $6 SHCTX "$0\.htm" ""
453
${WordFind} "$6" "-" "+1{" $6
454
${If} "$6" != "FirefoxHTML"
455
WriteRegStr SHCTX "$0\.htm" "" "FirefoxHTML$5"
456
${EndIf}
457
458
ReadRegStr $6 SHCTX "$0\.html" ""
459
${WordFind} "$6" "-" "+1{" $6
460
${If} "$6" != "FirefoxHTML"
461
WriteRegStr SHCTX "$0\.html" "" "FirefoxHTML$5"
462
${EndIf}
463
464
ReadRegStr $6 SHCTX "$0\.shtml" ""
465
${WordFind} "$6" "-" "+1{" $6
466
${If} "$6" != "FirefoxHTML"
467
WriteRegStr SHCTX "$0\.shtml" "" "FirefoxHTML$5"
468
${EndIf}
469
470
ReadRegStr $6 SHCTX "$0\.xht" ""
471
${WordFind} "$6" "-" "+1{" $6
472
${If} "$6" != "FirefoxHTML"
473
WriteRegStr SHCTX "$0\.xht" "" "FirefoxHTML$5"
474
${EndIf}
475
476
ReadRegStr $6 SHCTX "$0\.xhtml" ""
477
${WordFind} "$6" "-" "+1{" $6
478
${If} "$6" != "FirefoxHTML"
479
WriteRegStr SHCTX "$0\.xhtml" "" "FirefoxHTML$5"
480
${EndIf}
481
482
483
${AddAssociationIfNoneExist} ".pdf" "FirefoxHTML$5"
484
${AddAssociationIfNoneExist} ".oga" "FirefoxHTML$5"
485
${AddAssociationIfNoneExist} ".ogg" "FirefoxHTML$5"
486
${AddAssociationIfNoneExist} ".ogv" "FirefoxHTML$5"
487
${AddAssociationIfNoneExist} ".pdf" "FirefoxHTML$5"
488
${AddAssociationIfNoneExist} ".webm" "FirefoxHTML$5"
489
${AddAssociationIfNoneExist} ".svg" "FirefoxHTML$5"
490
${AddAssociationIfNoneExist} ".webp" "FirefoxHTML$5"
491
492
; An empty string is used for the 5th param because FirefoxHTML is not a
493
; protocol handler
494
${AddDisabledDDEHandlerValues} "FirefoxHTML$5" "$2" "$8,1" \
495
"${AppRegName} HTML Document" ""
496
497
${AddDisabledDDEHandlerValues} "FirefoxURL$5" "$2" "$8,1" "${AppRegName} URL" \
498
"true"
499
; An empty string is used for the 4th & 5th params because the following
500
; protocol handlers already have a display name and the additional keys
501
; required for a protocol handler.
502
${AddDisabledDDEHandlerValues} "ftp" "$2" "$8,1" "" ""
503
${AddDisabledDDEHandlerValues} "http" "$2" "$8,1" "" ""
504
${AddDisabledDDEHandlerValues} "https" "$2" "$8,1" "" ""
505
${AddDisabledDDEHandlerValues} "mailto" "$2" "$8,1" "" ""
506
!macroend
507
!define SetHandlers "!insertmacro SetHandlers"
508
509
; Adds the HKLM\Software\Clients\StartMenuInternet\Firefox-[pathhash] registry
510
; entries (does not use SHCTX).
511
;
512
; The values for StartMenuInternet are only valid under HKLM and there can only
513
; be one installation registerred under StartMenuInternet per application since
514
; the key name is derived from the main application executable.
515
;
516
; In Windows 8 this changes slightly, you can store StartMenuInternet entries in
517
; HKCU. The icon in start menu for StartMenuInternet is deprecated as of Win7,
518
; but the subkeys are what's important. Control panel default programs looks
519
; for them only in HKLM pre win8.
520
;
521
; The StartMenuInternet key and friends are documented at
523
;
524
; This function also writes our RegisteredApplications entry, which gets us
525
; listed in the Settings app's default browser options on Windows 8+, and in
526
; Set Program Access and Defaults on earlier versions.
527
!macro SetStartMenuInternet RegKey
528
${GetLongPath} "$INSTDIR\${FileMainEXE}" $8
529
${GetLongPath} "$INSTDIR\uninstall\helper.exe" $7
530
531
; If we already have keys at the old FIREFOX.EXE path, then just update those.
532
; We have to be careful to update the existing keys in place so that we don't
533
; create duplicate keys for the same installation, or cause Windows to think
534
; something "suspicious" has happened and it should reset the default browser.
535
${StrFilter} "${FileMainEXE}" "+" "" "" $1
536
ReadRegStr $0 ${RegKey} "Software\Clients\StartMenuInternet\$1\DefaultIcon" ""
537
StrCpy $0 $0 -2
538
${If} $0 != $8
539
StrCpy $1 "${AppRegName}-$AppUserModelID"
540
StrCpy $2 "-$AppUserModelID"
541
${Else}
542
StrCpy $2 ""
543
${EndIf}
544
StrCpy $0 "Software\Clients\StartMenuInternet\$1"
545
546
WriteRegStr ${RegKey} "$0" "" "${BrandFullName}"
547
548
WriteRegStr ${RegKey} "$0\DefaultIcon" "" "$8,0"
549
550
; The Reinstall Command is defined at
552
WriteRegStr ${RegKey} "$0\InstallInfo" "HideIconsCommand" "$\"$7$\" /HideShortcuts"
553
WriteRegStr ${RegKey} "$0\InstallInfo" "ShowIconsCommand" "$\"$7$\" /ShowShortcuts"
554
WriteRegStr ${RegKey} "$0\InstallInfo" "ReinstallCommand" "$\"$7$\" /SetAsDefaultAppGlobal"
555
WriteRegDWORD ${RegKey} "$0\InstallInfo" "IconsVisible" 1
556
557
WriteRegStr ${RegKey} "$0\shell\open\command" "" "$\"$8$\""
558
559
WriteRegStr ${RegKey} "$0\shell\properties" "" "$(CONTEXT_OPTIONS)"
560
WriteRegStr ${RegKey} "$0\shell\properties\command" "" "$\"$8$\" -preferences"
561
562
WriteRegStr ${RegKey} "$0\shell\safemode" "" "$(CONTEXT_SAFE_MODE)"
563
WriteRegStr ${RegKey} "$0\shell\safemode\command" "" "$\"$8$\" -safe-mode"
564
565
; Capabilities registry keys
566
WriteRegStr ${RegKey} "$0\Capabilities" "ApplicationDescription" "$(REG_APP_DESC)"
567
WriteRegStr ${RegKey} "$0\Capabilities" "ApplicationIcon" "$8,0"
568
WriteRegStr ${RegKey} "$0\Capabilities" "ApplicationName" "${BrandShortName}"
569
570
WriteRegStr ${RegKey} "$0\Capabilities\FileAssociations" ".htm" "FirefoxHTML$2"
571
WriteRegStr ${RegKey} "$0\Capabilities\FileAssociations" ".html" "FirefoxHTML$2"
572
WriteRegStr ${RegKey} "$0\Capabilities\FileAssociations" ".shtml" "FirefoxHTML$2"
573
WriteRegStr ${RegKey} "$0\Capabilities\FileAssociations" ".xht" "FirefoxHTML$2"
574
WriteRegStr ${RegKey} "$0\Capabilities\FileAssociations" ".xhtml" "FirefoxHTML$2"
575
WriteRegStr ${RegKey} "$0\Capabilities\FileAssociations" ".svg" "FirefoxHTML$2"
576
WriteRegStr ${RegKey} "$0\Capabilities\FileAssociations" ".webp" "FirefoxHTML$2"
577
578
WriteRegStr ${RegKey} "$0\Capabilities\StartMenu" "StartMenuInternet" "$1"
579
580
WriteRegStr ${RegKey} "$0\Capabilities\URLAssociations" "ftp" "FirefoxURL$2"
581
WriteRegStr ${RegKey} "$0\Capabilities\URLAssociations" "http" "FirefoxURL$2"
582
WriteRegStr ${RegKey} "$0\Capabilities\URLAssociations" "https" "FirefoxURL$2"
583
WriteRegStr ${RegKey} "$0\Capabilities\URLAssociations" "mailto" "FirefoxURL$2"
584
585
WriteRegStr ${RegKey} "Software\RegisteredApplications" "$1" "$0\Capabilities"
586
587
; This key would be created by the Open With dialog when a user creates an
588
; association for us with a file type that we haven't registered as a handler
589
; for. We need to preemptively create it ourselves so that we can control the
590
; command line that's used to launch us in that situation. If it's too late
591
; and one already exists, then we need to edit its command line to make sure
592
; it contains the -osint flag.
593
ReadRegStr $6 ${RegKey} "Software\Classes\Applications\${FileMainEXE}\shell\open\command" ""
594
${If} $6 != ""
595
${GetPathFromString} "$6" $6
596
WriteRegStr ${RegKey} "Software\Classes\Applications\${FileMainEXE}\shell\open\command" \
597
"" "$\"$6$\" -osint -url $\"%1$\""
598
${Else}
599
WriteRegStr ${RegKey} "Software\Classes\Applications\${FileMainEXE}\shell\open\command" \
600
"" "$\"$8$\" -osint -url $\"%1$\""
601
; Make sure files associated this way use the document icon instead of the
602
; application icon.
603
WriteRegStr ${RegKey} "Software\Classes\Applications\${FileMainEXE}\DefaultIcon" \
604
"" "$8,1"
605
; If we're going to create this key at all, we also need to list our supported
606
; file types in it, because otherwise we'll be shown as a suggestion for every
607
; single file type, whether we support it in any way or not.
608
WriteRegStr ${RegKey} "Software\Classes\Applications\${FileMainEXE}\SupportedTypes" \
609
".htm" ""
610
WriteRegStr ${RegKey} "Software\Classes\Applications\${FileMainEXE}\SupportedTypes" \
611
".html" ""
612
WriteRegStr ${RegKey} "Software\Classes\Applications\${FileMainEXE}\SupportedTypes" \
613
".shtml" ""
614
WriteRegStr ${RegKey} "Software\Classes\Applications\${FileMainEXE}\SupportedTypes" \
615
".xht" ""
616
WriteRegStr ${RegKey} "Software\Classes\Applications\${FileMainEXE}\SupportedTypes" \
617
".xhtml" ""
618
WriteRegStr ${RegKey} "Software\Classes\Applications\${FileMainEXE}\SupportedTypes" \
619
".svg" ""
620
WriteRegStr ${RegKey} "Software\Classes\Applications\${FileMainEXE}\SupportedTypes" \
621
".webp" ""
622
${EndIf}
623
!macroend
624
!define SetStartMenuInternet "!insertmacro SetStartMenuInternet"
625
626
; Add registry keys to support the Firefox 32 bit to 64 bit migration. These
627
; registry entries are not removed on uninstall at this time. After the Firefox
628
; 32 bit to 64 bit migration effort is completed these registry entries can be
629
; removed during install, post update, and uninstall.
630
!macro Set32to64DidMigrateReg
631
${GetLongPath} "$INSTDIR" $1
632
; These registry keys are always in the 32 bit hive since they are never
633
; needed by a Firefox 64 bit install unless it has been updated from Firefox
634
; 32 bit.
635
SetRegView 32
636
637
!ifdef HAVE_64BIT_BUILD
638
639
; Running Firefox 64 bit on Windows 64 bit
640
ClearErrors
641
ReadRegDWORD $2 HKLM "Software\Mozilla\${AppName}\32to64DidMigrate" "$1"
642
; If there were no errors then the system was updated from Firefox 32 bit to
643
; Firefox 64 bit and if the value is already 1 then the registry value has
644
; already been updated in the HKLM registry.
645
${IfNot} ${Errors}
646
${AndIf} $2 != 1
647
ClearErrors
648
WriteRegDWORD HKLM "Software\Mozilla\${AppName}\32to64DidMigrate" "$1" 1
649
${If} ${Errors}
650
; There was an error writing to HKLM so just write it to HKCU
651
WriteRegDWORD HKCU "Software\Mozilla\${AppName}\32to64DidMigrate" "$1" 1
652
${Else}
653
; This will delete the value from HKCU if it exists
654
DeleteRegValue HKCU "Software\Mozilla\${AppName}\32to64DidMigrate" "$1"
655
${EndIf}
656
${EndIf}
657
658
ClearErrors
659
ReadRegDWORD $2 HKCU "Software\Mozilla\${AppName}\32to64DidMigrate" "$1"
660
; If there were no errors then the system was updated from Firefox 32 bit to
661
; Firefox 64 bit and if the value is already 1 then the registry value has
662
; already been updated in the HKCU registry.
663
${IfNot} ${Errors}
664
${AndIf} $2 != 1
665
WriteRegDWORD HKCU "Software\Mozilla\${AppName}\32to64DidMigrate" "$1" 1
666
${EndIf}
667
668
!else
669
670
; Running Firefox 32 bit
671
${If} ${RunningX64}
672
${OrIf} ${IsNativeARM64}
673
; Running Firefox 32 bit on a Windows 64 bit system
674
ClearErrors
675
ReadRegDWORD $2 HKLM "Software\Mozilla\${AppName}\32to64DidMigrate" "$1"
676
; If there were errors the value doesn't exist yet.
677
${If} ${Errors}
678
ClearErrors
679
WriteRegDWORD HKLM "Software\Mozilla\${AppName}\32to64DidMigrate" "$1" 0
680
; If there were errors write the value in HKCU.
681
${If} ${Errors}
682
WriteRegDWORD HKCU "Software\Mozilla\${AppName}\32to64DidMigrate" "$1" 0
683
${EndIf}
684
${EndIf}
685
${EndIf}
686
687
!endif
688
689
ClearErrors
690
SetRegView lastused
691
!macroend
692
!define Set32to64DidMigrateReg "!insertmacro Set32to64DidMigrateReg"
693
694
; The IconHandler reference for FirefoxHTML can end up in an inconsistent state
695
; due to changes not being detected by the IconHandler for side by side
696
; installs (see bug 268512). The symptoms can be either an incorrect icon or no
697
; icon being displayed for files associated with Firefox (does not use SHCTX).
698
!macro FixShellIconHandler RegKey
699
; Find the correct key to update, either FirefoxHTML or FirefoxHTML-[PathHash]
700
StrCpy $3 "FirefoxHTML-$AppUserModelID"
701
ClearErrors
702
ReadRegStr $0 ${RegKey} "Software\Classes\$3\DefaultIcon" ""
703
${If} ${Errors}
704
StrCpy $3 "FirefoxHTML"
705
${EndIf}
706
707
ClearErrors
708
ReadRegStr $1 ${RegKey} "Software\Classes\$3\ShellEx\IconHandler" ""
709
${Unless} ${Errors}
710
ReadRegStr $1 ${RegKey} "Software\Classes\$3\DefaultIcon" ""
711
${GetLongPath} "$INSTDIR\${FileMainEXE}" $2
712
${If} "$1" != "$2,1"
713
WriteRegStr ${RegKey} "Software\Classes\$3\DefaultIcon" "" "$2,1"
714
${EndIf}
715
${EndUnless}
716
!macroend
717
!define FixShellIconHandler "!insertmacro FixShellIconHandler"
718
719
; Add Software\Mozilla\ registry entries (uses SHCTX).
720
!macro SetAppKeys
721
; Check if this is an ESR release and if so add registry values so it is
722
; possible to determine that this is an ESR install (bug 726781).
723
ClearErrors
724
${WordFind} "${UpdateChannel}" "esr" "E#" $3
725
${If} ${Errors}
726
StrCpy $3 ""
727
${Else}
728
StrCpy $3 " ESR"
729
${EndIf}
730
731
${GetLongPath} "$INSTDIR" $8
732
StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion}$3 (${ARCH} ${AB_CD})\Main"
733
${WriteRegStr2} $TmpVal "$0" "Install Directory" "$8" 0
734
${WriteRegStr2} $TmpVal "$0" "PathToExe" "$8\${FileMainEXE}" 0
735
736
StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion}$3 (${ARCH} ${AB_CD})\Uninstall"
737
${WriteRegStr2} $TmpVal "$0" "Description" "${BrandFullNameInternal} ${AppVersion}$3 (${ARCH} ${AB_CD})" 0
738
739
StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion}$3 (${ARCH} ${AB_CD})"
740
${WriteRegStr2} $TmpVal "$0" "" "${AppVersion}$3 (${ARCH} ${AB_CD})" 0
741
${If} "$3" == ""
742
DeleteRegValue SHCTX "$0" "ESR"
743
${Else}
744
${WriteRegDWORD2} $TmpVal "$0" "ESR" 1 0
745
${EndIf}
746
747
StrCpy $0 "Software\Mozilla\${BrandFullNameInternal} ${AppVersion}$3\bin"
748
${WriteRegStr2} $TmpVal "$0" "PathToExe" "$8\${FileMainEXE}" 0
749
750
StrCpy $0 "Software\Mozilla\${BrandFullNameInternal} ${AppVersion}$3\extensions"
751
${WriteRegStr2} $TmpVal "$0" "Components" "$8\components" 0
752
${WriteRegStr2} $TmpVal "$0" "Plugins" "$8\plugins" 0
753
754
StrCpy $0 "Software\Mozilla\${BrandFullNameInternal} ${AppVersion}$3"
755
${WriteRegStr2} $TmpVal "$0" "GeckoVer" "${GREVersion}" 0
756
${If} "$3" == ""
757
DeleteRegValue SHCTX "$0" "ESR"
758
${Else}
759
${WriteRegDWORD2} $TmpVal "$0" "ESR" 1 0
760
${EndIf}
761
762
StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}$3"
763
${WriteRegStr2} $TmpVal "$0" "" "${GREVersion}" 0
764
${WriteRegStr2} $TmpVal "$0" "CurrentVersion" "${AppVersion}$3 (${ARCH} ${AB_CD})" 0
765
!macroend
766
!define SetAppKeys "!insertmacro SetAppKeys"
767
768
; Add uninstall registry entries. This macro tests for write access to determine
769
; if the uninstall keys should be added to HKLM or HKCU.
770
!macro SetUninstallKeys
771
; Check if this is an ESR release and if so add registry values so it is
772
; possible to determine that this is an ESR install (bug 726781).
773
ClearErrors
774
${WordFind} "${UpdateChannel}" "esr" "E#" $3
775
${If} ${Errors}
776
StrCpy $3 ""
777
${Else}
778
StrCpy $3 " ESR"
779
${EndIf}
780
781
StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} ${AppVersion}$3 (${ARCH} ${AB_CD})"
782
783
StrCpy $2 ""
784
ClearErrors
785
WriteRegStr HKLM "$0" "${BrandShortName}InstallerTest" "Write Test"
786
${If} ${Errors}
787
; If the uninstall keys already exist in HKLM don't create them in HKCU
788
ClearErrors
789
ReadRegStr $2 "HKLM" $0 "DisplayName"
790
${If} $2 == ""
791
; Otherwise we don't have any keys for this product in HKLM so proceeed
792
; to create them in HKCU. Better handling for this will be done in:
793
; Bug 711044 - Better handling for 2 uninstall icons
794
StrCpy $1 "HKCU"
795
SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
796
${EndIf}
797
ClearErrors
798
${Else}
799
StrCpy $1 "HKLM"
800
SetShellVarContext all ; Set SHCTX to all users (e.g. HKLM)
801
DeleteRegValue HKLM "$0" "${BrandShortName}InstallerTest"
802
${EndIf}
803
804
${If} $2 == ""
805
${GetLongPath} "$INSTDIR" $8
806
807
; Write the uninstall registry keys
808
${WriteRegStr2} $1 "$0" "Comments" "${BrandFullNameInternal} ${AppVersion}$3 (${ARCH} ${AB_CD})" 0
809
${WriteRegStr2} $1 "$0" "DisplayIcon" "$8\${FileMainEXE},0" 0
810
${WriteRegStr2} $1 "$0" "DisplayName" "${BrandFullNameInternal} ${AppVersion}$3 (${ARCH} ${AB_CD})" 0
811
${WriteRegStr2} $1 "$0" "DisplayVersion" "${AppVersion}" 0
812
${WriteRegStr2} $1 "$0" "HelpLink" "${HelpLink}" 0
813
${WriteRegStr2} $1 "$0" "InstallLocation" "$8" 0
814
${WriteRegStr2} $1 "$0" "Publisher" "Mozilla" 0
815
${WriteRegStr2} $1 "$0" "UninstallString" "$\"$8\uninstall\helper.exe$\"" 0
816
DeleteRegValue SHCTX "$0" "URLInfoAbout"
817
; Don't add URLUpdateInfo which is the release notes url except for the release
818
; and esr channels since nightly, aurora, and beta do not have release notes.
819
; Note: URLUpdateInfo is only defined in the official branding.nsi.
820
!ifdef URLUpdateInfo
821
!ifndef BETA_UPDATE_CHANNEL
822
${WriteRegStr2} $1 "$0" "URLUpdateInfo" "${URLUpdateInfo}" 0
823
!endif
824
!endif
825
${WriteRegStr2} $1 "$0" "URLInfoAbout" "${URLInfoAbout}" 0
826
${WriteRegDWORD2} $1 "$0" "NoModify" 1 0
827
${WriteRegDWORD2} $1 "$0" "NoRepair" 1 0
828
829
${GetSize} "$8" "/S=0K" $R2 $R3 $R4
830
${WriteRegDWORD2} $1 "$0" "EstimatedSize" $R2 0
831
832
${If} "$TmpVal" == "HKLM"
833
SetShellVarContext all ; Set SHCTX to all users (e.g. HKLM)
834
${Else}
835
SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
836
${EndIf}
837
${EndIf}
838
!macroend
839
!define SetUninstallKeys "!insertmacro SetUninstallKeys"
840
841
; Due to a bug when associating some file handlers, only SHCTX was checked for
842
; some file types such as ".pdf". SHCTX is set to HKCU or HKLM depending on
843
; whether the installer has write access to HKLM. The bug would happen when
844
; HCKU was checked and didn't exist since programs aren't required to set the
845
; HKCU Software\Classes keys when associating handlers. The fix uses the merged
846
; view in HKCR to check for existance of an existing association. This macro
847
; cleans affected installations by removing the HKLM and HKCU value if it is set
848
; to FirefoxHTML when there is a value for PersistentHandler or by removing the
849
; HKCU value when the HKLM value has a value other than an empty string.
850
!macro FixBadFileAssociation FILE_TYPE
851
; Only delete the default value in case the key has values for OpenWithList,
852
; OpenWithProgids, PersistentHandler, etc.
853
ReadRegStr $0 HKCU "Software\Classes\${FILE_TYPE}" ""
854
${WordFind} "$0" "-" "+1{" $0
855
ReadRegStr $1 HKLM "Software\Classes\${FILE_TYPE}" ""
856
${WordFind} "$1" "-" "+1{" $1
857
ReadRegStr $2 HKCR "${FILE_TYPE}\PersistentHandler" ""
858
${If} "$2" != ""
859
; Since there is a persistent handler remove FirefoxHTML as the default
860
; value from both HKCU and HKLM if it set to FirefoxHTML.
861
${If} "$0" == "FirefoxHTML"
862
DeleteRegValue HKCU "Software\Classes\${FILE_TYPE}" ""
863
${EndIf}
864
${If} "$1" == "FirefoxHTML"
865
DeleteRegValue HKLM "Software\Classes\${FILE_TYPE}" ""
866
${EndIf}
867
${ElseIf} "$0" == "FirefoxHTML"
868
; Since HKCU is set to FirefoxHTML remove FirefoxHTML as the default value
869
; from HKCU if HKLM is set to a value other than an empty string.
870
${If} "$1" != ""
871
DeleteRegValue HKCU "Software\Classes\${FILE_TYPE}" ""
872
${EndIf}
873
${EndIf}
874
!macroend
875
!define FixBadFileAssociation "!insertmacro FixBadFileAssociation"
876
877
; Add app specific handler registry entries under Software\Classes if they
878
; don't exist (does not use SHCTX).
879
!macro FixClassKeys
880
StrCpy $1 "SOFTWARE\Classes"
881
882
; File handler keys and name value pairs that may need to be created during
883
; install or upgrade.
884
ReadRegStr $0 HKCR ".shtml" "Content Type"
885
${If} "$0" == ""
886
StrCpy $0 "$1\.shtml"
887
${WriteRegStr2} $TmpVal "$1\.shtml" "" "shtmlfile" 0
888
${WriteRegStr2} $TmpVal "$1\.shtml" "Content Type" "text/html" 0
889
${WriteRegStr2} $TmpVal "$1\.shtml" "PerceivedType" "text" 0
890
${EndIf}
891
892
ReadRegStr $0 HKCR ".xht" "Content Type"
893
${If} "$0" == ""
894
${WriteRegStr2} $TmpVal "$1\.xht" "" "xhtfile" 0
895
${WriteRegStr2} $TmpVal "$1\.xht" "Content Type" "application/xhtml+xml" 0
896
${EndIf}
897
898
ReadRegStr $0 HKCR ".xhtml" "Content Type"
899
${If} "$0" == ""
900
${WriteRegStr2} $TmpVal "$1\.xhtml" "" "xhtmlfile" 0
901
${WriteRegStr2} $TmpVal "$1\.xhtml" "Content Type" "application/xhtml+xml" 0
902
${EndIf}
903
904
; Remove possibly badly associated file types
905
${FixBadFileAssociation} ".pdf"
906
${FixBadFileAssociation} ".oga"
907
${FixBadFileAssociation} ".ogg"
908
${FixBadFileAssociation} ".ogv"
909
${FixBadFileAssociation} ".pdf"
910
${FixBadFileAssociation} ".webm"
911
!macroend
912
!define FixClassKeys "!insertmacro FixClassKeys"
913
914
; Updates protocol handlers if their registry open command value is for this
915
; install location (uses SHCTX).
916
!macro UpdateProtocolHandlers
917
; Store the command to open the app with an url in a register for easy access.
918
${GetLongPath} "$INSTDIR\${FileMainEXE}" $8
919
StrCpy $2 "$\"$8$\" -osint -url $\"%1$\""
920
921
; Only set the file and protocol handlers if the existing one under HKCR is
922
; for this install location.
923
924
${IsHandlerForInstallDir} "FirefoxHTML-$AppUserModelID" $R9
925
${If} "$R9" == "true"
926
; An empty string is used for the 5th param because FirefoxHTML is not a
927
; protocol handler.
928
${AddDisabledDDEHandlerValues} "FirefoxHTML-$AppUserModelID" "$2" "$8,1" \
929
"${AppRegName} HTML Document" ""
930
${Else}
931
${IsHandlerForInstallDir} "FirefoxHTML" $R9
932
${If} "$R9" == "true"
933
${AddDisabledDDEHandlerValues} "FirefoxHTML" "$2" "$8,1" \
934
"${AppRegName} HTML Document" ""
935
${EndIf}
936
${EndIf}
937
938
${IsHandlerForInstallDir} "FirefoxURL-$AppUserModelID" $R9
939
${If} "$R9" == "true"
940
${AddDisabledDDEHandlerValues} "FirefoxURL-$AppUserModelID" "$2" "$8,1" \
941
"${AppRegName} URL" "true"
942
${Else}
943
${IsHandlerForInstallDir} "FirefoxURL" $R9
944
${If} "$R9" == "true"
945
${AddDisabledDDEHandlerValues} "FirefoxURL" "$2" "$8,1" \
946
"${AppRegName} URL" "true"
947
${EndIf}
948
${EndIf}
949
950
; An empty string is used for the 4th & 5th params because the following
951
; protocol handlers already have a display name and the additional keys
952
; required for a protocol handler.
953
${IsHandlerForInstallDir} "ftp" $R9
954
${If} "$R9" == "true"
955
${AddDisabledDDEHandlerValues} "ftp" "$2" "$8,1" "" ""
956
${EndIf}
957
958
${IsHandlerForInstallDir} "http" $R9
959
${If} "$R9" == "true"
960
${AddDisabledDDEHandlerValues} "http" "$2" "$8,1" "" ""
961
${EndIf}
962
963
${IsHandlerForInstallDir} "https" $R9
964
${If} "$R9" == "true"
965
${AddDisabledDDEHandlerValues} "https" "$2" "$8,1" "" ""
966
${EndIf}
967
968
${IsHandlerForInstallDir} "mailto" $R9
969
${If} "$R9" == "true"
970
${AddDisabledDDEHandlerValues} "mailto" "$2" "$8,1" "" ""
971
${EndIf}
972
!macroend
973
!define UpdateProtocolHandlers "!insertmacro UpdateProtocolHandlers"
974
975
!ifdef MOZ_MAINTENANCE_SERVICE
976
; Adds maintenance service certificate keys for the install dir.
977
; For the cert to work, it must also be signed by a trusted cert for the user.
978
!macro AddMaintCertKeys
979
Push $R0
980
; Allow main Mozilla cert information for updates
981
; This call will push the needed key on the stack
982
ServicesHelper::PathToUniqueRegistryPath "$INSTDIR"
983
Pop $R0
984
${If} $R0 != ""
985
; More than one certificate can be specified in a different subfolder
986
; for example: $R0\1, but each individual binary can be signed
987
; with at most one certificate. A fallback certificate can only be used
988
; if the binary is replaced with a different certificate.
989
; We always use the 64bit registry for certs.
990
${If} ${RunningX64}
991
${OrIf} ${IsNativeARM64}
992
SetRegView 64
993
${EndIf}
994
995
; PrefetchProcessName was originally used to experiment with deleting
996
; Windows prefetch as a speed optimization. It is no longer used though.
997
DeleteRegValue HKLM "$R0" "prefetchProcessName"
998
999
; Setting the Attempted value will ensure that a new Maintenance Service
1000
; install will never be attempted again after this from updates. The value
1001
; is used only to see if updates should attempt new service installs.
1002
WriteRegDWORD HKLM "Software\Mozilla\MaintenanceService" "Attempted" 1
1003
1004
; These values associate the allowed certificates for the current
1005
; installation.
1006
WriteRegStr HKLM "$R0\0" "name" "${CERTIFICATE_NAME}"
1007
WriteRegStr HKLM "$R0\0" "issuer" "${CERTIFICATE_ISSUER}"
1008
; These values associate the allowed certificates for the previous
1009
; installation, so that we can update from it cleanly using the
1010
; old updater.exe (which will still have this signature).
1011
WriteRegStr HKLM "$R0\1" "name" "${CERTIFICATE_NAME_PREVIOUS}"
1012
WriteRegStr HKLM "$R0\1" "issuer" "${CERTIFICATE_ISSUER_PREVIOUS}"
1013
${If} ${RunningX64}
1014
${OrIf} ${IsNativeARM64}
1015
SetRegView lastused
1016
${EndIf}
1017
ClearErrors
1018
${EndIf}
1019
; Restore the previously used value back
1020
Pop $R0
1021
!macroend
1022
!define AddMaintCertKeys "!insertmacro AddMaintCertKeys"
1023
!endif
1024
1025
!macro RegisterAccessibleHandler
1026
${RegisterDLL} "$INSTDIR\AccessibleHandler.dll"
1027
!macroend
1028
!define RegisterAccessibleHandler "!insertmacro RegisterAccessibleHandler"
1029
1030
!macro RegisterAccessibleMarshal
1031
${RegisterDLL} "$INSTDIR\AccessibleMarshal.dll"
1032
!macroend
1033
!define RegisterAccessibleMarshal "!insertmacro RegisterAccessibleMarshal"
1034
1035
; Removes various registry entries for reasons noted below (does not use SHCTX).
1036
!macro RemoveDeprecatedKeys
1037
StrCpy $0 "SOFTWARE\Classes"
1038
; Remove support for launching chrome urls from the shell during install or
1039
; update if the DefaultIcon is from firefox.exe (Bug 301073).
1040
${RegCleanAppHandler} "chrome"
1041
1042
; Remove protocol handler registry keys added by the MS shim
1043
DeleteRegKey HKLM "Software\Classes\Firefox.URL"
1044
DeleteRegKey HKCU "Software\Classes\Firefox.URL"
1045
!macroend
1046
!define RemoveDeprecatedKeys "!insertmacro RemoveDeprecatedKeys"
1047
1048
; Removes various directories and files for reasons noted below.
1049
!macro RemoveDeprecatedFiles
1050
; Remove the toplevel chrome.manifest added by bug 1295542.
1051
${If} ${FileExists} "$INSTDIR\chrome.manifest"
1052
Delete "$INSTDIR\chrome.manifest"
1053
${EndIf}
1054
1055
; Remove talkback if it is present (remove after bug 386760 is fixed)
1056
${If} ${FileExists} "$INSTDIR\extensions\talkback@mozilla.org"
1057
RmDir /r /REBOOTOK "$INSTDIR\extensions\talkback@mozilla.org"
1058
${EndIf}
1059
1060
; Remove the Java Console extension (bug 1165156)
1061
${If} ${FileExists} "$INSTDIR\extensions\{CAFEEFAC-0016-0000-0031-ABCDEFFEDCBA}"
1062
RmDir /r /REBOOTOK "$INSTDIR\extensions\{CAFEEFAC-0016-0000-0031-ABCDEFFEDCBA}"
1063
${EndIf}
1064
${If} ${FileExists} "$INSTDIR\extensions\{CAFEEFAC-0016-0000-0034-ABCDEFFEDCBA}"
1065
RmDir /r /REBOOTOK "$INSTDIR\extensions\{CAFEEFAC-0016-0000-0034-ABCDEFFEDCBA}"
1066
${EndIf}
1067
${If} ${FileExists} "$INSTDIR\extensions\{CAFEEFAC-0016-0000-0039-ABCDEFFEDCBA}"
1068
RmDir /r /REBOOTOK "$INSTDIR\extensions\{CAFEEFAC-0016-0000-0039-ABCDEFFEDCBA}"
1069
${EndIf}
1070
${If} ${FileExists} "$INSTDIR\extensions\{CAFEEFAC-0016-0000-0045-ABCDEFFEDCBA}"
1071
RmDir /r /REBOOTOK "$INSTDIR\extensions\{CAFEEFAC-0016-0000-0045-ABCDEFFEDCBA}"
1072
${EndIf}
1073
${If} ${FileExists} "$INSTDIR\extensions\{CAFEEFAC-0017-0000-0000-ABCDEFFEDCBA}"
1074
RmDir /r /REBOOTOK "$INSTDIR\extensions\{CAFEEFAC-0017-0000-0000-ABCDEFFEDCBA}"
1075
${EndIf}
1076
!macroend
1077
!define RemoveDeprecatedFiles "!insertmacro RemoveDeprecatedFiles"
1078
1079
; Converts specific partner distribution.ini from ansi to utf-8 (bug 882989)
1080
!macro FixDistributionsINI
1081
StrCpy $1 "$INSTDIR\distribution\distribution.ini"
1082
StrCpy $2 "$INSTDIR\distribution\utf8fix"
1083
StrCpy $0 "0" ; Default to not attempting to fix
1084
1085
; Check if the distribution.ini settings are for a partner build that needs
1086
; to have its distribution.ini converted from ansi to utf-8.
1087
${If} ${FileExists} "$1"
1088
${Unless} ${FileExists} "$2"
1089
ReadINIStr $3 "$1" "Preferences" "app.distributor"
1090
${If} "$3" == "yahoo"
1091
ReadINIStr $3 "$1" "Preferences" "app.distributor.channel"
1092
${If} "$3" == "de"
1093
${OrIf} "$3" == "es"
1094
${OrIf} "$3" == "e1"
1095
${OrIf} "$3" == "mx"
1096
StrCpy $0 "1"
1097
${EndIf}
1098
${EndIf}
1099
; Create the utf8fix so this only runs once
1100
FileOpen $3 "$2" w
1101
FileClose $3
1102
${EndUnless}
1103
${EndIf}
1104
1105
${If} "$0" == "1"
1106
StrCpy $0 "0"
1107
ClearErrors
1108
ReadINIStr $3 "$1" "Global" "version"
1109
${Unless} ${Errors}
1110
StrCpy $4 "$3" 2
1111
${If} "$4" == "1."
1112
StrCpy $4 "$3" "" 2 ; Everything after "1."
1113
${If} $4 < 23
1114
StrCpy $0 "1"
1115
${EndIf}
1116
${EndIf}
1117
${EndUnless}
1118
${EndIf}
1119
1120
${If} "$0" == "1"
1121
ClearErrors
1122
FileOpen $3 "$1" r
1123
${If} ${Errors}
1124
FileClose $3
1125
${Else}
1126
StrCpy $2 "$INSTDIR\distribution\distribution.new"
1127
ClearErrors
1128
FileOpen $4 "$2" w
1129
${If} ${Errors}
1130
FileClose $3
1131
FileClose $4
1132
${Else}
1133
StrCpy $0 "0" ; Default to not replacing the original distribution.ini
1134
${Do}
1135
FileReadByte $3 $5
1136
${If} $5 == ""
1137
${Break}
1138
${EndIf}
1139
${If} $5 == 233 ; ansi é
1140
StrCpy $0 "1"
1141
FileWriteByte $4 195
1142
FileWriteByte $4 169
1143
${ElseIf} $5 == 241 ; ansi ñ
1144
StrCpy $0 "1"
1145
FileWriteByte $4 195
1146
FileWriteByte $4 177
1147
${ElseIf} $5 == 252 ; ansi ü
1148
StrCpy $0 "1"
1149
FileWriteByte $4 195
1150
FileWriteByte $4 188
1151
${ElseIf} $5 < 128
1152
FileWriteByte $4 $5
1153
${EndIf}
1154
${Loop}
1155
FileClose $3
1156
FileClose $4
1157
${If} "$0" == "1"
1158
ClearErrors
1159
Rename "$1" "$1.bak"
1160
${Unless} ${Errors}
1161
Rename "$2" "$1"
1162
Delete "$1.bak"
1163
${EndUnless}
1164
${Else}
1165
Delete "$2"
1166
${EndIf}
1167
${EndIf}
1168
${EndIf}
1169
${EndIf}
1170
!macroend
1171
!define FixDistributionsINI "!insertmacro FixDistributionsINI"
1172
1173
; Adds a pinned shortcut to Task Bar on update for Windows 7 and above if this
1174
; macro has never been called before and the application is default (see
1175
; PinToTaskBar for more details).
1176
; Since defaults handling is handled by Windows in Win8 and later, we always
1177
; attempt to pin a taskbar on that OS. If Windows sets the defaults at
1178
; installation time, then we don't get the opportunity to run this code at
1179
; that time.
1180
!macro MigrateTaskBarShortcut
1181
${GetShortcutsLogPath} $0
1182
${If} ${FileExists} "$0"
1183
ClearErrors
1184
ReadINIStr $1 "$0" "TASKBAR" "Migrated"
1185
${If} ${Errors}
1186
ClearErrors
1187
WriteIniStr "$0" "TASKBAR" "Migrated" "true"
1188
WriteRegDWORD HKCU \
1189
"Software\Mozilla\${AppName}\Installer\$AppUserModelID" \
1190
"WasPinnedToTaskbar" 1
1191
${If} ${AtLeastWin7}
1192
; If we didn't run the stub installer, AddTaskbarSC will be empty.
1193
; We determine whether to pin based on whether we're the default
1194
; browser, or if we're on win8 or later, we always pin.
1195
${If} $AddTaskbarSC == ""
1196
; No need to check the default on Win8 and later
1197
${If} ${AtMostWin2008R2}
1198
; Check if the Firefox is the http handler for this user
1199
SetShellVarContext current ; Set SHCTX to the current user
1200
${IsHandlerForInstallDir} "http" $R9
1201
${If} $TmpVal == "HKLM"
1202
SetShellVarContext all ; Set SHCTX to all users
1203
${EndIf}
1204
${EndIf}
1205
${If} "$R9" == "true"
1206
${OrIf} ${AtLeastWin8}
1207
${PinToTaskBar}
1208
${EndIf}
1209
${ElseIf} $AddTaskbarSC == "1"
1210
${PinToTaskBar}
1211
${EndIf}
1212
${EndIf}
1213
${ElseIf} ${AtLeastWin10}
1214
${GetInstallerRegistryPref} "Software\Mozilla\${AppName}" \
1215
"installer.taskbarpin.win10.enabled" $2
1216
${If} $2 == "true"
1217
; On Windows 10, we may have previously tried to make a taskbar pin
1218
; and failed because the API we tried to use was blocked by the OS.
1219
; We have an option that works in more cases now, so we're going to try
1220
; again, but also record that we've done so by writing a particular
1221
; registry value, so that we don't continue to do this repeatedly.
1222
ClearErrors
1223
ReadRegDWORD $2 HKCU \
1224
"Software\Mozilla\${AppName}\Installer\$AppUserModelID" \
1225
"WasPinnedToTaskbar"
1226
${If} ${Errors}
1227
WriteRegDWORD HKCU \
1228
"Software\Mozilla\${AppName}\Installer\$AppUserModelID" \
1229
"WasPinnedToTaskbar" 1
1230
${If} $AddTaskbarSC != "0"
1231
${PinToTaskBar}
1232
${EndIf}
1233
${EndIf}
1234
${EndIf}
1235
${EndIf}
1236
${EndIf}
1237
!macroend
1238
!define MigrateTaskBarShortcut "!insertmacro MigrateTaskBarShortcut"
1239
1240
; Adds a pinned Task Bar shortcut on Windows 7 if there isn't one for the main
1241
; application executable already. Existing pinned shortcuts for the same
1242
; application model ID must be removed first to prevent breaking the pinned
1243
; item's lists but multiple installations with the same application model ID is
1244
; an edgecase. If removing existing pinned shortcuts with the same application
1245
; model ID removes a pinned pinned Start Menu shortcut this will also add a
1246
; pinned Start Menu shortcut.
1247
!macro PinToTaskBar
1248
${If} ${AtLeastWin7}
1249
StrCpy $8 "false" ; Whether a shortcut had to be created
1250
${IsPinnedToTaskBar} "$INSTDIR\${FileMainEXE}" $R9
1251
${If} "$R9" == "false"
1252
; Find an existing Start Menu shortcut or create one to use for pinning
1253
${GetShortcutsLogPath} $0
1254
${If} ${FileExists} "$0"
1255
ClearErrors
1256
ReadINIStr $1 "$0" "STARTMENU" "Shortcut0"
1257
${Unless} ${Errors}
1258
SetShellVarContext all ; Set SHCTX to all users
1259
${Unless} ${FileExists} "$SMPROGRAMS\$1"
1260
SetShellVarContext current ; Set SHCTX to the current user
1261
${Unless} ${FileExists} "$SMPROGRAMS\$1"
1262
StrCpy $8 "true"
1263
CreateShortCut "$SMPROGRAMS\$1" "$INSTDIR\${FileMainEXE}"
1264
${If} ${FileExists} "$SMPROGRAMS\$1"
1265
ShellLink::SetShortCutWorkingDirectory "$SMPROGRAMS\$1" \
1266
"$INSTDIR"
1267
${If} "$AppUserModelID" != ""
1268
ApplicationID::Set "$SMPROGRAMS\$1" "$AppUserModelID" "true"
1269
${EndIf}
1270
${EndIf}
1271
${EndUnless}
1272
${EndUnless}
1273
1274
${If} ${FileExists} "$SMPROGRAMS\$1"
1275
; Count of Start Menu pinned shortcuts before unpinning.
1276
${PinnedToStartMenuLnkCount} $R9
1277
1278
; Having multiple shortcuts pointing to different installations with
1279
; the same AppUserModelID (e.g. side by side installations of the
1280
; same version) will make the TaskBar shortcut's lists into an bad
1281
; state where the lists are not shown. To prevent this first
1282
; uninstall the pinned item.
1283
ApplicationID::UninstallPinnedItem "$SMPROGRAMS\$1"
1284
1285
; Count of Start Menu pinned shortcuts after unpinning.
1286
${PinnedToStartMenuLnkCount} $R8
1287
1288
; If there is a change in the number of Start Menu pinned shortcuts
1289
; assume that unpinning unpinned a side by side installation from
1290
; the Start Menu and pin this installation to the Start Menu.
1291
${Unless} $R8 == $R9
1292
; Pin the shortcut to the Start Menu. 5381 is the shell32.dll
1293
; resource id for the "Pin to Start Menu" string.
1294
InvokeShellVerb::DoIt "$SMPROGRAMS" "$1" "5381"
1295
${EndUnless}
1296
1297
${If} ${AtMostWin2012R2}
1298
; Pin the shortcut to the TaskBar. 5386 is the shell32.dll
1299
; resource id for the "Pin to Taskbar" string.
1300
InvokeShellVerb::DoIt "$SMPROGRAMS" "$1" "5386"
1301
${Else}
1302
; In Windows 10 the "Pin to Taskbar" resource was removed, so we
1303
; can't access the verb that way anymore. We have a create a
1304
; command key using the GUID that's assigned to this action and
1305
; then invoke that as a verb.
1306
ReadRegStr $R9 HKLM \
1307
"Software\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Windows.taskbarpin" \
1308
"ExplorerCommandHandler"
1309
WriteRegStr HKCU "Software\Classes\*\shell\${AppRegName}-$AppUserModelID" "ExplorerCommandHandler" $R9
1310
InvokeShellVerb::DoIt "$SMPROGRAMS" "$1" "${AppRegName}-$AppUserModelID"
1311
DeleteRegKey HKCU "Software\Classes\*\shell\${AppRegName}-$AppUserModelID"
1312
${EndIf}
1313
1314
; Delete the shortcut if it was created
1315
${If} "$8" == "true"
1316
Delete "$SMPROGRAMS\$1"
1317
${EndIf}
1318
${EndIf}
1319
1320
${If} $TmpVal == "HKCU"
1321
SetShellVarContext current ; Set SHCTX to the current user
1322
${Else}
1323
SetShellVarContext all ; Set SHCTX to all users
1324
${EndIf}
1325
${EndUnless}
1326
${EndIf}
1327
${EndIf}
1328
${EndIf}
1329
!macroend
1330
!define PinToTaskBar "!insertmacro PinToTaskBar"
1331
1332
; Removes the application's start menu directory along with its shortcuts if
1333
; they exist and if they exist creates a start menu shortcut in the root of the
1334
; start menu directory (bug 598779). If the application's start menu directory
1335
; is not empty after removing the shortucts the directory will not be removed
1336
; since these additional items were not created by the installer (uses SHCTX).
1337
!macro RemoveStartMenuDir
1338
${GetShortcutsLogPath} $0
1339
${If} ${FileExists} "$0"
1340
; Delete Start Menu Programs shortcuts, directory if it is empty, and
1341
; parent directories if they are empty up to but not including the start
1342
; menu directory.
1343
${GetLongPath} "$SMPROGRAMS" $1
1344
ClearErrors
1345
ReadINIStr $2 "$0" "SMPROGRAMS" "RelativePathToDir"
1346
${Unless} ${Errors}
1347
${GetLongPath} "$1\$2" $2
1348
${If} "$2" != ""
1349
; Delete shortucts in the Start Menu Programs directory.
1350
StrCpy $3 0
1351
${Do}
1352
ClearErrors
1353
ReadINIStr $4 "$0" "SMPROGRAMS" "Shortcut$3"
1354
; Stop if there are no more entries
1355
${If} ${Errors}
1356
${ExitDo}
1357
${EndIf}
1358
${If} ${FileExists} "$2\$4"
1359
ShellLink::GetShortCutTarget "$2\$4"
1360
Pop $5
1361
${If} "$INSTDIR\${FileMainEXE}" == "$5"
1362
Delete "$2\$4"
1363
${EndIf}
1364
${EndIf}
1365
IntOp $3 $3 + 1 ; Increment the counter
1366
${Loop}
1367
; Delete Start Menu Programs directory and parent directories
1368
${Do}
1369
; Stop if the current directory is the start menu directory
1370
${If} "$1" == "$2"
1371
${ExitDo}
1372
${EndIf}
1373
ClearErrors
1374
RmDir "$2"
1375
; Stop if removing the directory failed
1376
${If} ${Errors}
1377
${ExitDo}
1378
${EndIf}
1379
${GetParent} "$2" $2
1380
${Loop}
1381
${EndIf}
1382
DeleteINISec "$0" "SMPROGRAMS"
1383
${EndUnless}
1384
${EndIf}
1385
!macroend
1386
!define RemoveStartMenuDir "!insertmacro RemoveStartMenuDir"
1387
1388
; Creates the shortcuts log ini file with the appropriate entries if it doesn't
1389
; already exist.
1390
!macro CreateShortcutsLog
1391
${GetShortcutsLogPath} $0
1392
${Unless} ${FileExists} "$0"
1393
${LogStartMenuShortcut} "${BrandShortName}.lnk"
1394
${LogQuickLaunchShortcut} "${BrandShortName}.lnk"
1395
${LogDesktopShortcut} "${BrandShortName}.lnk"
1396
${EndUnless}
1397
!macroend
1398
!define CreateShortcutsLog "!insertmacro CreateShortcutsLog"
1399
1400
; The files to check if they are in use during (un)install so the restart is
1401
; required message is displayed. All files must be located in the $INSTDIR
1402
; directory.
1403
!macro PushFilesToCheck
1404
; The first string to be pushed onto the stack MUST be "end" to indicate
1405
; that there are no more files to check in $INSTDIR and the last string
1406
; should be ${FileMainEXE} so if it is in use the CheckForFilesInUse macro
1407
; returns after the first check.
1408
Push "end"
1409
Push "AccessibleHandler.dll"
1410
Push "AccessibleMarshal.dll"
1411
Push "IA2Marshal.dll"
1412
Push "freebl3.dll"
1413
Push "nssckbi.dll"
1414
Push "nspr4.dll"
1415
Push "nssdbm3.dll"
1416
Push "mozsqlite3.dll"
1417
Push "xpcom.dll"
1418
Push "crashreporter.exe"
1419
Push "default-browser-agent.exe"
1420
Push "minidump-analyzer.exe"
1421
Push "pingsender.exe"
1422
Push "updater.exe"
1423
Push "updateagent.exe"
1424
Push "${FileMainEXE}"
1425
!macroend
1426
!define PushFilesToCheck "!insertmacro PushFilesToCheck"
1427
1428
1429
; Pushes the string "true" to the top of the stack if the Firewall service is
1430
; running and pushes the string "false" to the top of the stack if it isn't.
1431
!define SC_MANAGER_ALL_ACCESS 0x3F
1432
!define SERVICE_QUERY_CONFIG 0x0001
1433
!define SERVICE_QUERY_STATUS 0x0004
1434
!define SERVICE_RUNNING 0x4
1435
1436
!macro IsFirewallSvcRunning
1437
Push $R9
1438
Push $R8
1439
Push $R7
1440
Push $R6
1441
Push "false"
1442
1443
System::Call 'advapi32::OpenSCManagerW(n, n, i ${SC_MANAGER_ALL_ACCESS}) i.R6'
1444
${If} $R6 != 0
1445
; MpsSvc is the Firewall service.
1446
; When opening the service with SERVICE_QUERY_CONFIG the return value will
1447
; be 0 if the service is not installed.
1448
System::Call 'advapi32::OpenServiceW(i R6, t "MpsSvc", i ${SERVICE_QUERY_CONFIG}) i.R7'
1449
${If} $R7 != 0
1450
System::Call 'advapi32::CloseServiceHandle(i R7) n'
1451
; Open the service with SERVICE_QUERY_STATUS so its status can be queried.
1452
System::Call 'advapi32::OpenServiceW(i R6, t "MpsSvc", i ${SERVICE_QUERY_STATUS}) i.R7'
1453
${EndIf}
1454
; Did the calls to OpenServiceW succeed?
1455
${If} $R7 != 0
1456
System::Call '*(i,i,i,i,i,i,i) i.R9'
1457
; Query the current status of the service.
1458
System::Call 'advapi32::QueryServiceStatus(i R7, i $R9) i'
1459
System::Call '*$R9(i, i.R8)'
1460
System::Free $R9
1461
System::Call 'advapi32::CloseServiceHandle(i R7) n'
1462
IntFmt $R8 "0x%X" $R8
1463
${If} $R8 == ${SERVICE_RUNNING}
1464
Pop $R9
1465
Push "true"
1466
${EndIf}
1467
${EndIf}
1468
System::Call 'advapi32::CloseServiceHandle(i R6) n'
1469
${EndIf}
1470
1471
Exch 1
1472
Pop $R6
1473
Exch 1
1474
Pop $R7
1475
Exch 1
1476
Pop $R8
1477
Exch 1
1478
Pop $R9
1479
!macroend
1480
!define IsFirewallSvcRunning "!insertmacro IsFirewallSvcRunning"
1481
!define un.IsFirewallSvcRunning "!insertmacro IsFirewallSvcRunning"
1482
1483
; Sets this installation as the default browser by setting the registry keys
1484
; under HKEY_CURRENT_USER via registry calls and using the AppAssocReg NSIS
1485
; plugin. This is a function instead of a macro so it is
1486
; easily called from an elevated instance of the binary. Since this can be
1487
; called by an elevated instance logging is not performed in this function.
1488
Function SetAsDefaultAppUserHKCU
1489
; See if we're using path hash suffixed registry keys for this install
1490
${GetLongPath} "$INSTDIR\${FileMainEXE}" $8
1491
${StrFilter} "${FileMainEXE}" "+" "" "" $R9
1492
ClearErrors
1493
ReadRegStr $0 HKCU "Software\Clients\StartMenuInternet\$R9\DefaultIcon" ""
1494
${If} ${Errors}
1495
${OrIf} ${AtMostWin2008R2}
1496
ClearErrors
1497
ReadRegStr $0 HKLM "Software\Clients\StartMenuInternet\$R9\DefaultIcon" ""
1498
${EndIf}
1499
StrCpy $0 $0 -2
1500
${If} $0 != $8
1501
${If} $AppUserModelID == ""
1502
${InitHashAppModelId} "$INSTDIR" "Software\Mozilla\${AppName}\TaskBarIDs"
1503
${EndIf}
1504
StrCpy $R9 "${AppRegName}-$AppUserModelID"
1505
${EndIf}
1506
1507
; Set ourselves as the user's selected StartMenuInternet browser, but only
1508
; if we have StartMenuInternet registry keys that are for this install.
1509
ClearErrors
1510
ReadRegStr $0 HKCU "Software\Clients\StartMenuInternet\$R9\DefaultIcon" ""
1511
${If} ${Errors}
1512
${OrIf} ${AtMostWin2008R2}
1513
ClearErrors
1514
ReadRegStr $0 HKLM "Software\Clients\StartMenuInternet\$R9\DefaultIcon" ""
1515
${EndIf}
1516
${Unless} ${Errors}
1517
${GetPathFromString} "$0" $0
1518
${GetParent} "$0" $0
1519
${If} ${FileExists} "$0"
1520
${GetLongPath} "$0" $0
1521
${If} "$0" == "$INSTDIR"
1522
; On Windows >= 8, this function cannot do anything to actually set
1523
; the default browser, it can only set up the registry entries to
1524
; allow the user to do so. Getting here means that those entries already
1525
; exist for this installation, we just found them, so there is nothing
1526
; more to be done.
1527
${If} ${AtLeastWin8}
1528
Return
1529
${Else}
1530
WriteRegStr HKCU "Software\Clients\StartMenuInternet" "" "$R9"
1531
${EndIf}
1532
${EndIf}
1533
${EndIf}
1534
${EndUnless}
1535
1536
SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
1537
1538
; It's unlikely that we didn't find a StartMenuInternet key above, but it is
1539
; possible; it likely would mean this copy of the application was extracted
1540
; directly from a ZIP file and the installer was never run.
1541
${If} ${AtLeastWin8}
1542
${SetStartMenuInternet} "HKCU"
1543
${FixShellIconHandler} "HKCU"
1544
${FixClassKeys} ; Does not use SHCTX
1545
${EndIf}
1546
1547
${SetHandlers}
1548
1549
; Only register as the handler if the app registry name
1550
; exists under the RegisteredApplications registry key. The protocol and
1551
; file handlers set previously at the user level will associate this install
1552
; as the default browser.
1553
ClearErrors
1554
ReadRegStr $0 HKLM "Software\RegisteredApplications" "$R9"
1555
${Unless} ${Errors}
1556
; This is all protected by a user choice hash in Windows 8 so it won't
1557
; help, but it also won't hurt.
1558
AppAssocReg::SetAppAsDefaultAll "$R9"
1559
${EndUnless}
1560
${RemoveDeprecatedKeys}
1561
${MigrateTaskBarShortcut}
1562
FunctionEnd
1563
1564
; Helper for updating the shortcut application model IDs.
1565
Function FixShortcutAppModelIDs
1566
${If} ${AtLeastWin7}
1567
${AndIf} "$AppUserModelID" != ""
1568
${UpdateShortcutAppModelIDs} "$INSTDIR\${FileMainEXE}" "$AppUserModelID" $0
1569
${EndIf}
1570
FunctionEnd
1571
1572
; Helper for adding Firewall exceptions during install and after app update.
1573
Function AddFirewallEntries
1574
${IsFirewallSvcRunning}
1575
Pop $0
1576
${If} "$0" == "true"
1577
liteFirewallW::AddRule "$INSTDIR\${FileMainEXE}" "${BrandShortName} ($INSTDIR)"
1578
${EndIf}
1579
FunctionEnd
1580
1581
; The !ifdef NO_LOG prevents warnings when compiling the installer.nsi due to
1582
; this function only being used by the uninstaller.nsi.
1583
!ifdef NO_LOG
1584
1585
Function SetAsDefaultAppUser
1586
; On Win8, we want to avoid having a UAC prompt since we'll already have
1587
; another action for control panel default browser selection popping up
1588
; to the user. Win8 is the first OS where the start menu keys can be
1589
; added into HKCU. The call to SetAsDefaultAppUserHKCU will have already
1590
; set the HKCU keys for SetStartMenuInternet.
1591
${If} ${AtLeastWin8}
1592
; Check if this is running in an elevated process
1593
ClearErrors
1594
${GetParameters} $0
1595
${GetOptions} "$0" "/UAC:" $0
1596
${If} ${Errors} ; Not elevated
1597
Call SetAsDefaultAppUserHKCU
1598
${Else} ; Elevated - execute the function in the unelevated process
1599
GetFunctionAddress $0 SetAsDefaultAppUserHKCU
1600
UAC::ExecCodeSegment $0
1601
${EndIf}
1602
Return ; Nothing more needs to be done
1603
${EndIf}
1604
1605
; Before Win8, it is only possible to set this installation of the application
1606
; as the StartMenuInternet handler if it was added to the HKLM
1607
; StartMenuInternet registry keys.
1609
1610
; Check if this install location registered as a StartMenuInternet client
1611
ClearErrors
1612
ReadRegStr $0 HKCU "Software\Clients\StartMenuInternet\${AppRegName}-$AppUserModelID\DefaultIcon" ""
1613
${If} ${Errors}
1614
${OrIf} ${AtMostWin2008R2}
1615
ClearErrors
1616
ReadRegStr $0 HKLM "Software\Clients\StartMenuInternet\${AppRegName}-$AppUserModelID\DefaultIcon" ""
1617
${EndIf}
1618
${If} ${Errors}
1619
${StrFilter} "${FileMainEXE}" "+" "" "" $R9
1620
ClearErrors
1621
ReadRegStr $0 HKCU "Software\Clients\StartMenuInternet\$R9\DefaultIcon" ""
1622
${If} ${Errors}
1623
${OrIf} ${AtMostWin2008R2}
1624
ClearErrors
1625
ReadRegStr $0 HKLM "Software\Clients\StartMenuInternet\$R9\DefaultIcon" ""
1626
${EndIf}
1627
${EndIf}
1628
1629
${Unless} ${Errors}
1630
${GetPathFromString} "$0" $0
1631
${GetParent} "$0" $0
1632
${If} ${FileExists} "$0"
1633
${GetLongPath} "$0" $0
1634
${If} "$0" == "$INSTDIR"
1635
; Check if this is running in an elevated process
1636
ClearErrors
1637
${GetParameters} $0
1638
${GetOptions} "$0" "/UAC:" $0
1639
${If} ${Errors} ; Not elevated
1640
Call SetAsDefaultAppUserHKCU
1641
${Else} ; Elevated - execute the function in the unelevated process
1642
GetFunctionAddress $0 SetAsDefaultAppUserHKCU
1643
UAC::ExecCodeSegment $0
1644
${EndIf}
1645
Return ; Nothing more needs to be done
1646
${EndIf}
1647
${EndIf}
1648
${EndUnless}
1649
1650
; The code after ElevateUAC won't be executed when the user:
1651
; a) is a member of the administrators group (e.g. elevation is required)
1652
; b) is not a member of the administrators group and chooses to elevate
1653
${ElevateUAC}
1654
1655
${SetStartMenuInternet} "HKLM"
1656
1657
SetShellVarContext all ; Set SHCTX to all users (e.g. HKLM)
1658
1659
${FixClassKeys} ; Does not use SHCTX
1660
${FixShellIconHandler} "HKLM"
1661
${RemoveDeprecatedKeys} ; Does not use SHCTX
1662
1663
ClearErrors
1664
${GetParameters} $0
1665
${GetOptions} "$0" "/UAC:" $0
1666
${If} ${Errors}
1667
Call SetAsDefaultAppUserHKCU
1668
${Else}
1669
GetFunctionAddress $0 SetAsDefaultAppUserHKCU
1670
UAC::ExecCodeSegment $0
1671
${EndIf}
1672
FunctionEnd
1673
!define SetAsDefaultAppUser "Call SetAsDefaultAppUser"
1674
1675
!endif ; NO_LOG
1676
1677
!ifdef MOZ_LAUNCHER_PROCESS
1678
!macro ResetLauncherProcessDefaults
1679
# By deleting these values, we remove remnants of any force-disable settings
1680
# that may have been set during the SHIELD study in 67. Note that this setting
1681
# was only intended to distinguish between test and control groups for the
1682
# purposes of the study, not as a user preference.
1683
DeleteRegValue HKCU ${MOZ_LAUNCHER_SUBKEY} "$INSTDIR\${FileMainEXE}|Launcher"
1684
DeleteRegValue HKCU ${MOZ_LAUNCHER_SUBKEY} "$INSTDIR\${FileMainEXE}|Browser"
1685
!macroend
1686
!define ResetLauncherProcessDefaults "!insertmacro ResetLauncherProcessDefaults"
1687
!endif
1688
1689
!ifdef MOZ_UPDATE_AGENT
1690
; Push, onto the stack, the command line used to register (or update) the
1691
; update agent scheduled task.
1692
;
1693
; InitHashAppModelId must have already been called to set $AppUserModelID,
1694
; if that is empty then an empty string will be pushed instead.
1695
;
1696
; COMMAND_BASE must be "register" or "update". Both will remove any
1697
; pre-existing task and register a new one, but "update" will first attempt
1698
; to copy some settings.
1699
!macro PushRegisterUpdateAgentTaskCommand COMMAND_BASE
1700
Push $0
1701
Push $1
1702
1703
Call IsUserAdmin
1704
Pop $0
1705
; Register the update agent to run as Local Service if the user is an admin...
1706
${If} $0 == "true"
1707
; ...and if we have HKLM write access
1708
${AndIf} $TmpVal == "HKLM"
1709
StrCpy $1 "${COMMAND_BASE}-task-local-service"
1710
${Else}
1711
; Otherwise attempt to register the task for the current user.
1712
; If we had previously registered the task while elevated, then we shouldn't
1713
; be able to replace it now with another task of the same name, so this
1714
; will fail harmlessly.
1715
StrCpy $1 "${COMMAND_BASE}-task"
1716
${EndIf}
1717
1718
${If} "$AppUserModelID" != ""
1719
StrCpy $0 '"$INSTDIR\updateagent.exe" $1 "${UpdateAgentFullName} $AppUserModelID" "$AppUserModelID" "$INSTDIR"'
1720
${Else}
1721
StrCpy $0 ''
1722
${EndIf}
1723
1724
Pop $1
1725
Exch $0
1726
!macroend
1727
!define PushRegisterUpdateAgentTaskCommand "!insertmacro PushRegisterUpdateAgentTaskCommand"
1728
!endif