Forum Discussion
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} ")
}
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.