# Script to set Google Chrome as default for specified file types and link types $fileTypes = @(".htm", ".html", ".mhtml", ".svg", ".shtml", ".webp", ".xht", ".xhtml") $linkTypes = @("http", "https") $setUserFtaPath = "C:\Scripts\Software\setuserfta.exe" # Function to check and set default app for file types function Set-DefaultFileTypeIfNeeded { param( [string]$fileType ) try { # Get the current default app for the file type $currentDefault = (Get-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$fileType\UserChoice" -ErrorAction SilentlyContinue).ProgId # Check if Chrome is not the default if ($currentDefault -ne "ChromeHTML") { Write-Host "Setting Chrome as default for file type $fileType" # Ensure setuserfta.exe path exists if (-not (Test-Path $setUserFtaPath)) { Write-Error "setuserfta.exe not found at $setUserFtaPath" return } # Run setuserfta.exe to set Chrome as default Start-Process $setUserFtaPath -ArgumentList "`"$fileType`" ChromeHTML" -Wait -NoNewWindow } else { Write-Host "Chrome is already the default for file type $fileType" } } catch { Write-Error "Error processing file type $fileType`: $_" } } # Function to check and set default app for link types function Set-DefaultLinkTypeIfNeeded { param( [string]$linkType ) try { # Registry path for URL protocol handlers $registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\$linkType\UserChoice" # Get the current default app for the link type $currentDefault = (Get-ItemProperty $registryPath -ErrorAction SilentlyContinue).ProgId # Check if Chrome is not the default if ($currentDefault -ne "ChromeHTML") { Write-Host "Setting Chrome as default for link type $linkType" # Run setuserfta.exe to set Chrome as default Start-Process $setUserFtaPath -ArgumentList "`"$linkType`" ChromeHTML" -Wait -NoNewWindow } else { Write-Host "Chrome is already the default for link type $linkType" } } catch { Write-Error "Error processing link type $linkType`: $_" } } # Process each file type foreach ($type in $fileTypes) { Set-DefaultFileTypeIfNeeded -fileType $type } # Process each link type foreach ($type in $linkTypes) { Set-DefaultLinkTypeIfNeeded -linkType $type } Write-Host "File and link type default app check completed."