From 09c9eeb48e95b22e2e6dfa14ab7ec9cbbfe3c6eb Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Jun 2025 09:16:23 -0700 Subject: [PATCH] Fix default browser detection for Windows 11 24H2 by checking UserChoiceLatest registry key (#40035) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary This PR fixes an issue where PowerToys Web Search and PowerToys Run would always open Microsoft Edge instead of the user's default browser on Windows 11 24H2, even when a different browser like Firefox was set as the default. ## Root Cause Windows 11 24H2 introduced a change where default browser associations are now stored in a new registry location: - **New location**: `HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoiceLatest` - **Old location**: `HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice` PowerToys was only checking the old registry location, causing it to fail to find the default browser and fall back to Microsoft Edge. ## Changes Made Updated both `DefaultBrowserInfo.cs` files to check the new registry location first, then fall back to the old location for backward compatibility: 1. **Command Palette Web Search**: `src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Helpers/DefaultBrowserInfo.cs` 2. **PowerToys Run**: `src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs` **Before**: ```csharp var progId = GetRegistryValue( @"HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice", "ProgId"); ``` **After**: ```csharp var progId = GetRegistryValue( @"HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoiceLatest", "ProgId") ?? GetRegistryValue( @"HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice", "ProgId"); ``` ## Testing - Verified the fallback logic works correctly with a test application - Confirmed both affected files are updated with the same pattern - Ensured backward compatibility with older Windows versions ## Impact This fix ensures that: - Users on Windows 11 24H2 will have their default browser respected - Older Windows versions continue to work as before - No breaking changes are introduced Fixes #39794. --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: crutkas <1462282+crutkas@users.noreply.github.com> --- .../Helpers/DefaultBrowserInfo.cs | 7 +++++-- .../launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Helpers/DefaultBrowserInfo.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Helpers/DefaultBrowserInfo.cs index 646cda1142..90eb0e1c3b 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Helpers/DefaultBrowserInfo.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.WebSearch/Helpers/DefaultBrowserInfo.cs @@ -79,8 +79,11 @@ public static class DefaultBrowserInfo try { var progId = GetRegistryValue( - @"HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice", - "ProgId"); + @"HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoiceLatest", + "ProgId") + ?? GetRegistryValue( + @"HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice", + "ProgId"); var appName = GetRegistryValue($@"HKEY_CLASSES_ROOT\{progId}\Application", "ApplicationName") ?? GetRegistryValue($@"HKEY_CLASSES_ROOT\{progId}", "FriendlyTypeName"); diff --git a/src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs b/src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs index 64493e23e2..b848ceb654 100644 --- a/src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs +++ b/src/modules/launcher/Wox.Plugin/Common/DefaultBrowserInfo.cs @@ -80,8 +80,11 @@ namespace Wox.Plugin.Common try { string progId = GetRegistryValue( - @"HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice", - "ProgId"); + @"HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoiceLatest", + "ProgId") + ?? GetRegistryValue( + @"HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice", + "ProgId"); string appName = GetRegistryValue($@"HKEY_CLASSES_ROOT\{progId}\Application", "ApplicationName") ?? GetRegistryValue($@"HKEY_CLASSES_ROOT\{progId}", "FriendlyTypeName");