tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit dac5415bd4929e67f9520b7d149148bba6e517b7
parent c3bc83c52bfec78ce37621fd16cb28a701645e1a
Author: Duncan McIntosh <dmcintosh@mozilla.com>
Date:   Wed, 22 Oct 2025 15:50:00 +0000

Bug 1991927 - Check the DesktopLauncherAppInstalled registry key instead of the shortcut log when uninstalling the desktop launcher. r=cdupuis,browser-installer-reviewers

The desktop launcher is placed on the desktop of whoever happens to
install Firefox. However, it is _removed_ from the desktop of whoever
uninstalls it, which might not be the same user. (This is the same
before and after this commit.) This means that, if we're not careful, we
could remove an unrelated file off of the uninstaller runner's desktop,
so we'd like to know whether that user even has a desktop launcher.

The original approach was to add the desktop launcher into the shortcut
log, as done in bug 1983083. However, that is a per-system log, and thus
we wouldn't be able to tell _which_ user has a desktop launcher; plus,
we require admin access (meaning that launchers added after bug 1992115
might not be uninstalled). The new approach is the registry key: it's
carried with the user profile and we don't need admin access to change
it.

Additionally, ensure that the registry key is always made as long as the
file exists in the end, to actually fix bug 1991927. (This actually was
a slight issue before---I think we would copy a new launcher if the user
installed Firefox from the launcher and then deleted the launcher.)

This isn't perfect, since it just checks for FileExists afterwards, so
an existing file will be co-opted, defeating the point. I don't think
this is easily fixable, although it'd be nice to at some point; main
problem is that after bug 1983963, the desktop launcher will lock itself
during the installation.  Even if that is fixed (NT mutex?), we still
wouldn't know whether the file needs updating or not.

[0]: https://phabricator.services.mozilla.com/D267693

Differential Revision: https://phabricator.services.mozilla.com/D269299

Diffstat:
Mbrowser/installer/windows/nsis/shared.nsh | 3+--
Mbrowser/installer/windows/nsis/uninstaller.nsi | 12++++++++++++
Mtoolkit/mozapps/installer/windows/nsis/common.nsh | 9---------
3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/browser/installer/windows/nsis/shared.nsh b/browser/installer/windows/nsis/shared.nsh @@ -336,9 +336,8 @@ Function InstallDesktopLauncher ClearErrors ; Copy the launcher into the user's Desktop with an appropriate name CopyFiles /SILENT /FILESONLY "$INSTDIR\desktop-launcher\desktop-launcher.exe" "$DESKTOP\${BrandShortName}.exe" - ${IfNot} ${Errors} + ${If} ${FileExists} "$DESKTOP\${BrandShortName}.exe" WriteRegDWORD HKCU "Software\Mozilla\${BrandFullNameInternal}" DesktopLauncherAppInstalled 1 - ${LogDesktopShortcut} "${BrandShortName}.exe" ${EndIf} FunctionEnd diff --git a/browser/installer/windows/nsis/uninstaller.nsi b/browser/installer/windows/nsis/uninstaller.nsi @@ -444,6 +444,18 @@ Section "Uninstall" ClearErrors ${EndIf} + ReadRegDWORD $R4 HKCU "Software\Mozilla\${BrandFullNameInternal}" DesktopLauncherAppInstalled + ${IfNot} ${Errors} + ${AndIf} $R4 == "1" + ; The current user had a desktop launcher at some point, so remove it. + SetShellVarContext current + Delete "$DESKTOP\${BrandShortName}.exe" + ${IfNot} ${Errors} + DeleteRegValue HKCU "Software\Mozilla\${BrandFullNameInternal}" DesktopLauncherAppInstalled + ${EndIf} + ${EndIf} + ClearErrors + SetShellVarContext current ; Set SHCTX to HKCU ${un.RegCleanMain} "Software\Mozilla" ${un.RegCleanPrefs} "Software\Mozilla\${AppName}" diff --git a/toolkit/mozapps/installer/windows/nsis/common.nsh b/toolkit/mozapps/installer/windows/nsis/common.nsh @@ -3674,13 +3674,6 @@ ${EndIf} ${If} ${FileExists} "$DESKTOP\$R8" - ${If} "$R8" == "${BrandShortName}.exe" - ; This is a copy of the desktop launcher that we installed, - ; so it should be removed. - Delete "$DESKTOP\$R8" - ${Continue} - ${EndIf} - ShellLink::GetShortCutTarget "$DESKTOP\$R8" Pop $R5 ${${_MOZFUNC_UN}GetLongPath} "$R5" $R5 @@ -3944,8 +3937,6 @@ FindNext $R6 $R8 ${Loop} - DeleteRegValue HKCU "Software\Mozilla\${BrandFullNameInternal}" DesktopLauncherAppInstalled - ClearErrors Pop $R4