Ask a Question

Change Default Web Browser


Change Default Web Browser

Has anyone scripted a way to change the default web browser in Windows10 during a test run? I am able to open the Default apps window, but can't access the various browser options by name, only through keyboard strokes (ie [Tab] and [Enter]), which won't work as it seems the order of the browsers can vary from one machine to another.


I've been using Object Browser and Spy Tool to try to figure out what I need to add to my project's UI Automation list of accepted windows (at least I think this is what I need to do) but haven't come across the correct combination yet.


This is my initial JavaScript function that works, but relies on the browser options being in a specific order:

function TESTsetDefaultBrowser(){

  Sys.Desktop.Keys("[Win]choose a default web browser");
  // select web browser
  // tab to desired browser

I want to replace the last line with something like Object.ClickItem("Chrome");


Here's the Default Apps window in the Object Browser:ObjectBrowser.PNG



And here's the items I've added to the project's list of UIAutomation accepted windows:UIAutomationList.PNG


Any insight is appreciated. Thanks!

Community Hero

There is likely a commandline way to do this, but my question is what is the end goal for this? Are you testing Windows, or are you testing your application? Why do you need to set the default browser in a Test Complete test?


Click the Accept as Solution button if my answer has helped

I have not been able to find a command line way to do this, so I was hoping someone out there had or had automated this process through the UI successfully.


No, I am not testing Windows. My tested desktop app launches web apps (which is what's under test here) to the default browser. Previously, running Windows 7, I had automated the process of changing the default browser through the UI in order to test all supported browsers. Now, with Windows 10, the UI window has changed and this code does not work.

I haven't tested this personally, but you might try something like this in powershell. 


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} ")



Click the Accept as Solution button if my answer has helped

Thanks, I did try a similar way using a .vbs script based on the responses here: how-to-automate-setting-chrome-as-default-browser-in-windows-10 

But that doesn't actually set the browser for me. It did open the Default apps window, and will open the Email setting but not actually choose anything.

I'm guessing based on the line: 

[System.Windows.Forms.SendKeys]::SendWait("{TAB} {TAB}{TAB} ")

that there is still some UI action going on to get to the web browser settings or the chrome choice? I don't know as I'm not familiar with powershell or vbs scripts, but will keep researching/tinkering with it.

After much research I came across these two programs to set the default browser programatically for the current user. It seems that it has become a lot less simple than it used to be thanks to a hash that is now a part of the registry editor in recent versions of Windows 10.



SmartBear Alumni (Retired)

@mboyce  thank you a lot for digging into this and sharing with us! 

Sonya Mihaljova
Community and Education Specialist

Showing results for 
Search instead for 
Did you mean: