Changing Default Web Browser via a Software Package

Changing Default Web Browser via a Software Package. SRW/TK-KB29

Written by Fernando

Last published at: February 28th, 2024

In the event that you want to change the default browser to something else (i.e. Chrome, Firefox, Opera, Brave) you will need to use it as a software package that can be found in our portal.

Once you download it, add it to your Management Console.

Please update the variables in the Install script tab based on the Web Browser Configuration below or from the ReadMe.txt in the software package zip file.

 

Web Browser Configuration

For Google Chrome:
$assoc1 = "http"
$assoc2 = "https"
$assoc3 = ".htm"
$assoc4 = ".html"
$progid = "ChromeHTML"

For Firefox:
$assoc1 =  "http"
$assoc2 = "https"
$assoc3 = ".htm"
$assoc4 = ".html"
$progid = "FirefoxHTML"

For Opera:
$assoc1 = "http"
$assoc2 = "https"
$assoc3 = ".htm"
$assoc4 = ".html"
$progid = "OperaStable"

For Brave:
$assoc1 = "http"
$assoc2 = "https"
$assoc3 = ".htm"
$assoc4 = ".html"
$progid = "BraveHTML"

Delete

 

You can use the below script

PowerShell Script

##### ONLY UPDATE the below variables according to your browser #####

#Please review the ReadMe.txt for information on other web browser configuration

$browsername = "Google Chrome"

$assoc1 = "http"
$assoc2 = "https"
$assoc3 = ".htm"
$assoc4 = ".html"

$progid = "ChromeHTML"


##### DO NOT MODIFY THE CODE BELOW #####

$installer =  "DefaultBrowser.tst"
$version = "1"

#Package Name for logs folder creation
$SWName = (Split-Path $installer -Leaf).Split('.')[0] + "_$version"

#Get Current Time/Date
$date = Get-Date -Format "MM-dd-yyyy_HH-mm-ss"


#Log File 
$logname = "$env:SystemDrive\TST_Logs\$SWNAme\$SWName"+"_$date.txt"

Start-Transcript $logname


#Running process to set browser as default

if ( (Get-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice\).ProgId -eq "ChromeHTML" )
{
   Write-Host "$browsername already configured as default browser" -ForegroundColor Green
}
else
{
   # Copy file to TEMP
   Write-Host "Copying file to $env:TEMP" -ForegroundColor Green
   Copy-Item SetUserFTA.exe -Destination $env:TEMP -Force

   Write-Host "Setting $browsername as default browser" -ForegroundColor Green
   Write-Host "Updating $assoc1 browser association to $browsername" -ForegroundColor Green
   Start-Process "$env:TEMP\SetUserFTA.exe" -ArgumentList "$assoc1 $progid" -Wait

   Write-Host "Updating $assoc2 browser association to $browsername" -ForegroundColor Green
   Start-Process "$env:TEMP\SetUserFTA.exe" -ArgumentList "$assoc2 $progid" -Wait

   Write-Host "Updating $assoc3 browser association to $browsername" -ForegroundColor Green
   Start-Process "$env:TEMP\SetUserFTA.exe" -ArgumentList "$assoc3 $progid" -Wait

   Write-Host "Updating $assoc4 browser association to $browsername" -ForegroundColor Green
   Start-Process "$env:TEMP\SetUserFTA.exe" -ArgumentList "$assoc4 $progid" -Wait


   #Remove leftovers
   Write-Host "Removing leftovers" -ForegroundColor Green
   Remove-Item "$env:TEMP\SetUserFTA.exe" -Force

}


Stop-Transcript it

Delete