37

I've tried setting default in the reg keys:

hkeycu>software>microsoft>windows>shell>associations>urlassociations>http and https.

Tried using master_preference file.

Tried using command switch --make-default-browser.

So far these aren't working.

Any help would be appreciated. Open to any to batch files, registry keys, file replacements/edits... basically anything I can automate.

5

13 Answers 13

17

Have you tried making a .vbs file to set Chrome as the default browser automatically?

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\system32\control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=google%20chrome"
WScript.Sleep 1200
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
WScript.Quit

Reference: comment by user "Raz" in Making IE the default browser in Windows 10 during OSD

6
  • Wow, that actually worked! Thanks a lot for this; I've been wanting a way to do this for ages!
    – Sam
    Apr 5, 2017 at 23:47
  • 1
    Also, you can simplify the SendKeys bits into just WshShell.SendKeys "{TAB} {TAB}{TAB} ".
    – Sam
    Apr 14, 2017 at 3:29
  • 2
    I've noticed that this makes Chrome the default for all file types it can open. This overrides the default for opening PDFs to Chrome which isn't preferred in my particular situation. Would it be possible to avoid the PDF filetype being modified? (.html, .shtml, .htm, etc - pretty much everything except PDF). I suppose I'm looking to replicate the behaviour of changing 'Web Browser' in "Default Apps" (automatically, and ideally silently).
    – Ellipsis
    Jan 26, 2018 at 8:52
  • 4
    Doesn't work in Windows 10 1809
    – Deleted
    Jun 11, 2019 at 4:54
  • 2
    This answer stopped working in Windows 10 1803. Instead, use this answer.
    – Sam
    Apr 9, 2020 at 21:43
14

To change default browser in Windows 10 try the tool SetDefaultBrowser – Set the Default Browser per command line or script by Christoph Kolbicz.

The following worked fine for me:

SetDefaultBrowser.exe HKLM "Google Chrome"
4
  • 1
    This should be the accepted answer
    – Sam
    Apr 9, 2020 at 21:43
  • I'm happy to report that this does not affect which app opens PDFs by default. So far, this works great for me. Fast and reliable. May 28, 2020 at 17:42
  • 1
    cannot use it, the antivirus used by my company detects this page as bad reputation Sep 20, 2022 at 8:11
  • Great pointer; still works in Windows 11. Now also available via Chocolatey: choco install setdefaultbrowser -y
    – mklement0
    Aug 11, 2023 at 14:53
7

The answer from Judy Li still worked for me on 2021-01-04 with the latest windows 10 built. However, I had to update the the number of tab's and sleep commands.

The updated steps are:

  1. Create a VBS files with the code below
  2. Open folder shell:startup with [win]+[r] or file explorer
  3. Store the file in the startup folder to execute the script with each restart

VBS Code

Set WshShell = WScript.CreateObject("WScript.Shell")

' Open the default settings window
WshShell.Run "%windir%\system32\control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=google%20chrome"
WScript.Sleep 5000 ' Wait until open (adjust if necessary)

' Adjust number of tabs until you reach the browser choice setting
WshShell.SendKeys "{TAB}" 
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"

' Open the browser choice menu
WshShell.SendKeys " " 
WScript.Sleep 500 ' Wait until open

WshShell.SendKeys "{TAB}" ' Move down one selection
WshShell.SendKeys " " ' Set current selection as default browser

WScript.Sleep 500 ' Wait until open
' Uncomment the line below to outomatically close the settings window
' WshShell.SendKeys "%{F4}" 
WScript.Quit
6

Here is the PowerShell version of the Judy Li / Raz solution:

function Set-ChromeAsDefaultBrowser {
    Add-Type -AssemblyName 'System.Windows.Forms'
    Start-Process $env:windir\system32\control.exe -ArgumentList '/name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=google%20chrome'
    Sleep 2
    [System.Windows.Forms.SendKeys]::SendWait("{TAB} {TAB}{TAB} ")
}
1
  • What does the part \pageAdvancedSettings?pszAppName=google%20chrome do? I don't see any difference when omitting this part. Aug 20, 2021 at 7:27
4

The Default Application Associations for all users are stored in the following file:

C:\Windows\System32\OEMDefaultAssociations.xml

Find extensions or protocols that use edge and change them to chrome, for example, you can replace the following associations:

<Association Identifier=".htm" ProgId="MSEdgeHTM" ApplicationName="Microsoft Edge" />
<Association Identifier=".html" ProgId="MSEdgeHTM" ApplicationName="Microsoft Edge" />
<Association Identifier="http" ProgId="MSEdgeHTM" ApplicationName="Microsoft Edge" />
<Association Identifier="https" ProgId="MSEdgeHTM" ApplicationName="Microsoft Edge" />

To open in chrome instead:

<Association Identifier=".htm" ProgId="ChromeHTML" ApplicationName="Google Chrome" />
<Association Identifier=".html" ProgId="ChromeHTML" ApplicationName="Google Chrome" />
<Association Identifier="http" ProgId="ChromeHTML" ApplicationName="Google Chrome" />
<Association Identifier="https" ProgId="ChromeHTML" ApplicationName="Google Chrome" />

You can change whatever associations you'd like, but should leave the rest in place. I have a script that pulls this file down from an S3 bucket and applies it as part of the machine provisioning process.

For example, here's my entire OEMDefaultAssociations.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<DefaultAssociations>
  <Association Identifier=".3g2" ProgId="WMP11.AssocFile.3G2" ApplicationName="Windows Media Player" />
  <Association Identifier=".3gp" ProgId="WMP11.AssocFile.3GP" ApplicationName="Windows Media Player" />
  <Association Identifier=".3gp2" ProgId="WMP11.AssocFile.3G2" ApplicationName="Windows Media Player" />
  <Association Identifier=".3gpp" ProgId="WMP11.AssocFile.3GP" ApplicationName="Windows Media Player" />
  <Association Identifier=".aac" ProgId="WMP11.AssocFile.ADTS" ApplicationName="Windows Media Player" />
  <Association Identifier=".adt" ProgId="WMP11.AssocFile.ADTS" ApplicationName="Windows Media Player" />
  <Association Identifier=".adts" ProgId="WMP11.AssocFile.ADTS" ApplicationName="Windows Media Player" />
  <Association Identifier=".avi" ProgId="WMP11.AssocFile.AVI" ApplicationName="Windows Media Player" />
  <Association Identifier=".bmp" ProgId="PBrush" ApplicationName="Paint" />
  <Association Identifier=".dib" ProgId="PBrush" ApplicationName="Paint" />
  <Association Identifier=".flac" ProgId="WMP11.AssocFile.FLAC" ApplicationName="Windows Media Player" />
  <Association Identifier=".gif" ProgId="PBrush" ApplicationName="Paint" />
  <Association Identifier=".jfif" ProgId="PBrush" ApplicationName="Paint" />
  <Association Identifier=".jpe" ProgId="PBrush" ApplicationName="Paint" />
  <Association Identifier=".jpeg" ProgId="PBrush" ApplicationName="Paint" />
  <Association Identifier=".jpg" ProgId="PBrush" ApplicationName="Paint" />
  <Association Identifier=".m2t" ProgId="WMP11.AssocFile.M2TS" ApplicationName="Windows Media Player" />
  <Association Identifier=".m2ts" ProgId="WMP11.AssocFile.M2TS" ApplicationName="Windows Media Player" />
  <Association Identifier=".m3u" ProgId="WMP11.AssocFile.m3u" ApplicationName="Windows Media Player" />
  <Association Identifier=".m4a" ProgId="WMP11.AssocFile.M4A" ApplicationName="Windows Media Player" />
  <Association Identifier=".m4v" ProgId="WMP11.AssocFile.MP4" ApplicationName="Windows Media Player" />
  <Association Identifier=".mkv" ProgId="WMP11.AssocFile.MKV" ApplicationName="Windows Media Player" />
  <Association Identifier=".mod" ProgId="WMP11.AssocFile.MPEG" ApplicationName="Windows Media Player" />
  <Association Identifier=".mov" ProgId="WMP11.AssocFile.MOV" ApplicationName="Windows Media Player" />
  <Association Identifier=".MP2" ProgId="WMP11.AssocFile.MP3" ApplicationName="Windows Media Player" />
  <Association Identifier=".mp3" ProgId="WMP11.AssocFile.MP3" ApplicationName="Windows Media Player" />
  <Association Identifier=".mp4" ProgId="WMP11.AssocFile.MP4" ApplicationName="Windows Media Player" />
  <Association Identifier=".mp4v" ProgId="WMP11.AssocFile.MP4" ApplicationName="Windows Media Player" />
  <Association Identifier=".mpa" ProgId="WMP11.AssocFile.MPEG" ApplicationName="Windows Media Player" />
  <Association Identifier=".MPE" ProgId="WMP11.AssocFile.MPEG" ApplicationName="Windows Media Player" />
  <Association Identifier=".mpeg" ProgId="WMP11.AssocFile.MPEG" ApplicationName="Windows Media Player" />
  <Association Identifier=".mpg" ProgId="WMP11.AssocFile.MPEG" ApplicationName="Windows Media Player" />
  <Association Identifier=".mpv2" ProgId="WMP11.AssocFile.MPEG" ApplicationName="Windows Media Player" />
  <Association Identifier=".mts" ProgId="WMP11.AssocFile.M2TS" ApplicationName="Windows Media Player" />
  <Association Identifier=".png" ProgId="PBrush" ApplicationName="Paint" />
  <Association Identifier=".tif" ProgId="PhotoViewer.FileAssoc.Tiff" ApplicationName="Windows Photo Viewer" />
  <Association Identifier=".tiff" ProgId="PhotoViewer.FileAssoc.Tiff" ApplicationName="Windows Photo Viewer" />
  <Association Identifier=".TS" ProgId="WMP11.AssocFile.TTS" ApplicationName="Windows Media Player" />
  <Association Identifier=".TTS" ProgId="WMP11.AssocFile.TTS" ApplicationName="Windows Media Player" />
  <Association Identifier=".txt" ProgId="txtfile" ApplicationName="Notepad" />
  <Association Identifier=".url" ProgId="IE.AssocFile.URL" ApplicationName="Internet Browser" />
  <Association Identifier=".wav" ProgId="WMP11.AssocFile.WAV" ApplicationName="Windows Media Player" />
  <Association Identifier=".website" ProgId="IE.AssocFile.WEBSITE" ApplicationName="Internet Explorer" />
  <Association Identifier=".wm" ProgId="WMP11.AssocFile.ASF" ApplicationName="Windows Media Player" />
  <Association Identifier=".wma" ProgId="WMP11.AssocFile.WMA" ApplicationName="Windows Media Player" />
  <Association Identifier=".wmv" ProgId="WMP11.AssocFile.WMV" ApplicationName="Windows Media Player" />
  <Association Identifier=".WPL" ProgId="WMP11.AssocFile.WPL" ApplicationName="Windows Media Player" />
  <Association Identifier=".htm" ProgId="ChromeHTML" ApplicationName="Google Chrome" />
  <Association Identifier=".html" ProgId="ChromeHTML" ApplicationName="Google Chrome" />
  <Association Identifier=".url" ProgId="IE.AssocFile.URL" ApplicationName="Google Chrome" />
  <Association Identifier=".webp" ProgId="ChromeHTML" ApplicationName="Google Chrome" />
  <Association Identifier="ftp" ProgId="ChromeHTML" ApplicationName="Google Chrome" />
  <Association Identifier="http" ProgId="ChromeHTML" ApplicationName="Google Chrome" />
  <Association Identifier="https" ProgId="ChromeHTML" ApplicationName="Google Chrome" />
</DefaultAssociations>
4
  • Question is about making chrome default browser, not making it default program for some file types. Apr 9, 2020 at 15:53
  • 4
    well...what is a "default browser" except the program that gets launched when the user clicks a link to visit a web page?
    – NitrusCS
    Apr 9, 2020 at 22:29
  • 1
    I changed it and it does not work
    – Bersan
    Jul 19, 2022 at 11:01
  • Thank you for taking the time to write this up. Nothing was coming up on my google hits and this is the ONLY technique that makes any sense for a VDI type machine.
    – Spence
    Oct 10, 2022 at 2:22
2

The old control.exe stopped working for me today. I changed it to ms-settings:defaultapps.

Set WshShell = WScript.CreateObject("WScript.Shell")

' Open the default settings window
WshShell.Run "ms-settings:defaultapps"
WScript.Sleep 5000 ' Wait until open (adjust if necessary)

' Adjust number of tabs until you reach the browser choice setting
WshShell.SendKeys "{TAB}" 
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"

' Open the browser choice menu
WshShell.SendKeys " " 
WScript.Sleep 500 ' Wait until open

WshShell.SendKeys "{TAB}" ' Move down one selection
WshShell.SendKeys " " ' Set current selection as default browser

WScript.Sleep 500 ' Wait until open
' Uncomment the line below to outomatically close the settings window
WshShell.SendKeys "%{F4}" 
WScript.Quit
1
  • 1
    This works like a charm with the latest W10 build.
    – versvs
    Aug 3, 2022 at 7:33
1

This is not fully automated but reduces the steps required. Go to Settings, find "Default Apps" and right click on it and choose "Pin to Start". You can then get back to the selection screen in 2 clicks.

1

This works for me (Windows 10 21H2 using Microsoft Edge as default browser which is on top of the list of Web browser apps):

Set WshShell = WScript.CreateObject("WScript.Shell")

' Open the default settings window
WshShell.Run "ms-settings:defaultapps"
WScript.Sleep 1500 ' Wait until open (adjust if necessary)

' Adjust number of tabs until you reach the browser choice setting
WshShell.SendKeys "{TAB}" 
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"

' Open the browser choice menu
WshShell.SendKeys "{ENTER}" 
'WshShell.SendKeys " " 
WScript.Sleep 500 ' Wait until open

'WshShell.SendKeys "{TAB}" ' Move down one selection
WshShell.SendKeys " " ' Set current selection as default browser

WScript.Sleep 500 ' Wait until open
' Uncomment the line below to automatically close the settings window
WshShell.SendKeys "%{F4}" 
WScript.Quit
1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Apr 24, 2022 at 9:27
0

I modified the script above so that it will only change the default browser and not any of the other settings (mail, pdf, etc.) So this mimics changing the default browser usuing the Default Apps in Windows 10.

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\system32\control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=google%20chrome"
WScript.Sleep 1200
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"   
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys " "
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys " "
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys " "
WshShell.SendKeys "{DOWN}"
WshShell.SendKeys " "
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
WScript.Quit
0

Thanks a ton @BenH. You just saved my day.

On Server 2016, I had to use TABENTERTAB instead of TABTABTAB and it is working perfectly fine !

    function Set-ChromeAsDefaultBrowser {
    Add-Type -AssemblyName 'System.Windows.Forms'
    Start-Process $env:windir\system32\control.exe -ArgumentList '/name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=google%20chrome'
    Sleep 2
    [System.Windows.Forms.SendKeys]::SendWait("{TAB} {ENTER} {TAB}")
}
0
function Set-DefaultBrowser {
Add-Type -AssemblyName 'System.Windows.Forms'
Start-Process $env:windir\system32\control.exe -LoadUserProfile -Wait -ArgumentList '/name Microsoft.DefaultPrograms /page pageDefaultProgram\pageAdvancedSettings?pszAppName=Firefox-308046B0AF4A39CB'
Sleep 10
[System.Windows.Forms.SendKeys]::SendWait("{TAB}{TAB}{TAB}{TAB}{TAB} {ENTER}{ENTER} ")
}
Set-DefaultBrowser;

Worked for me in GCP Windows 10 image in setting Chrome as default browser.

0

Let me attempt a summary as of Windows 11:

  • Aldis's helpful answer points to a third-party utility, SetDefaultBrowser.exe, which works robustly, because it doesn't rely on GUI scripting, i.e. on simulating user input programmatically, which is invariably brittle (doesn't always work) and cannot be used from environments that run without a Windows desktop.

  • The other answers here are GUI-scripting solutions - and most no longer work in recent version of Windows 10 and on Windows 11.

The only reason to use GUI scripting is if downloading said third-party utility (whose license is very permissive) is not an option.

Here's a PowerShell-based GUI-scripting solution that works in Windows 11 and presumably in Windows 10 too, but note:

  • As with any GUI scripting solution:

    • Fundamentally, it only works when run in an environment with a Windows desktop (i.e., it won't work when run via PowerShell remoting or from a scheduled task that runs whether or not a user is logged on, for instance).

    • It may stop working over time, as the targeted GUI may change.

  • If the Windows Settings app happens to be open when the function starts, it is forcefully terminated, so as to prevent the state of an existing window from interfering with the GUI scripting.

  • You can paste the Set-DefaultBrowser function below into your $PROFILE file if you want it to be available in future PowerShell sessions.

Assuming that the function Set-DefaultBrowser is already defined in your session (see below - just copying and pasting with Ctrl+V in an interactive PowerShell session should work), you can use it as follows::

Set-DefaultBrowser 'Google Chrome'
  • Use the target browser's display name as shown in the Default Apps page of the Settings App, which you can open with Start-Process ms-settings:defaultapps.

    • Other common display names are 'Brave' and 'Microsoft Edge'.
  • You'll see simulated user activity for ca. 3 seconds during which no user action should be taken.

    • If you want to visually verify that the change was effective, add the -OpenSampleUrl switch; separately, if you want to inspect the state of the Settings app after the GUI-scripting attempt, use switch -KeepSettingsOpen.

Set-DefaultBrowser source code:

  • Once defined, run Set-DefaultBrowser -? for concise help, and help Set-DefaultBrowser for detailed help.
function Set-DefaultBrowser {
  <#
.SYNOPSIS
  Sets the default web browser for the current user (Windows only).

.DESCRIPTION
  Specify the display name of the target browser, 
  as shown in the Default Apps page of the Settings app.

  Examples: 'Brave', 'Google Chrome', 'Microsoft Edge'

  IMPORTANT: 
    * Uses GUI SCRIPTING, which implies:
      * This script can only run in sessions with a visible desktop.
      * As all GUI scripting, it is *brittle*.
    * If the Windwos Settings app is currently open, it will
      be forcefully closed first.
  
.PARAMETER BrowserDisplayName
  Specify the display name of the target browser, 
  as shown in the Default Apps page of the Settings app.
  (Start-Process ms-settings:defaultapps)

  If you use a substring, be sure that it matches the 
  desired application (as the first match).

  Also be sure that the name matches an actual installed
  *browser* application.

.PARAMETER KeepSettingsOpen
  Keeps the Settings app open after having made the change.
  By default, it is closed automatically.

.PARAMETER OpenSampleUrl
  Opens URL https://example.org in the default browser after
  having made the change, for visual verification that the change
  took effect.

.EXAMPLE
  Set-DefaultBrowser Brave
  Makes Brave the default browser for the current user.

.EXAMPLE
  Set-DefaultBrowser 'Google Chrome' -KeepSettingsOpen
  Makes Chrome the default browser for the current user 
  and leaves the Settings app open after doing so.

.EXAMPLE
  Set-DefaultBrowser 'Microsoft Edge' -OpenSampleUrl
  Makes Edge the default browser for the current user 
  and opens a sample URL afterwards for visual verification
  that the change took effect.
#>

  [CmdletBinding(PositionalBinding = $false)]
  param(
    [Parameter(Mandatory, Position = 0)]
    [string] $BrowserDisplayName,
    [switch] $KeepSettingsOpen,
    [switch] $OpenSampleUrl
  )

  if ($env:OS -ne 'Windows_NT') { throw 'This script runs on Windows only.' }

  # If the Settings app is currently open, it could be in a state that interferes
  # with the GUI scripting below.
  # Therefore, we kill any existing instance.
  Stop-Process -ErrorAction Ignore -Name SystemSettings
  # If you'd rather not kill an existing instance, use the following:
  #   if (Get-Process -ErrorAction Ignore SystemSettings) { throw "The Settings application is currently open. Close it before running this script." }

  # Launch the Default Apps page of the Settings app.
  Start-Process ms-settings:defaultapps

  # Wait for the Settings page to open and be ready for user input.
  # You may have to tweak this.
  # !! Curiously, the SystemSettings process *initially, briefly* has a non-zero
  # !! .MainWindowHandle property, which becomes zero once the window actually shows.
  # !! We take this transition to imply that the windows is ready for user input.
  $ps = Get-Process -ErrorAction Stop SystemSettings
  do {
    Start-Sleep -Milliseconds 100
    $ps.Refresh()
  } while ([int] $ps.MainWindowHandle)
  Start-Sleep -Milliseconds 200 # Sleep a little, to be safe.

  # Start sending keystrokes.
  $shell = New-Object -ComObject WScript.Shell

  # Tab to the "Set defaults for applications" search field.
  # Sleep a little between the keystrokes, for more predictable results.
  foreach ($i in 1..4) { $shell.SendKeys('{TAB}'); Start-Sleep -Milliseconds 30 }

  # Send the target browser's display name, which triggers a search.
  $shell.SendKeys($BrowserDisplayName)

  # Select the (first) search result to go to its details page.
  Start-Sleep -Milliseconds 100
  $shell.SendKeys('{TAB} ')

  # Sleep a little so that the application-details page has a chance to open,
  # then click the 'Set Default` button.
  Start-Sleep -Milliseconds 500
  $shell.SendKeys(' ')

  # Close the window, unless requested not to.
  if (-not $KeepSettingsOpen) {
    $shell.SendKeys('%{F4}')
  }

  # Open a sample URL in the new default browser, if requested.
  if ($OpenSampleUrl) {
    Start-Process https://example.org
  }

}
-1

Take the script from Judy Li’s answer and tweak it.

Option Explicit
Dim oShell, sWinDir
Set oShell = WScript.CreateObject("WScript.Shell")
sWinDir = oShell.ExpandEnvironmentStrings("%WINDIR%")
oShell.Run sWinDir & "\system32\control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram"
Set oShell = Nothing
WScript.Quit

Save it on your desktop as a .vbs file (e.g., SetDefaultProgams.vbs).  Double clicking it will bring up the more familiar Set Default Programs with the list on the left, like previous versions of Windows 10.

(Of course there are other ways to invoke a program / script.  You could put it on your Start Menu, or run it through CMD or PowerShell.)

This script was tested by me on Windows version 10.0.16299.192.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .