From 07e548f90e9523dc6cf30090844bbf531c9bc693 Mon Sep 17 00:00:00 2001 From: Elliot Chernofsky Date: Thu, 25 Apr 2024 20:51:49 -0400 Subject: [PATCH] Make Chrome the Default for .html Use the new `VM-Set-Open-With-Association` helper function to open .html files with Chrome by default. Remove also the Desktop shortcut that is created during installation. --- packages/googlechrome.vm/googlechrome.vm.nuspec | 4 ++-- .../googlechrome.vm/tools/chocolateyinstall.ps1 | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/googlechrome.vm/googlechrome.vm.nuspec b/packages/googlechrome.vm/googlechrome.vm.nuspec index 38e02806e..b93e9873d 100644 --- a/packages/googlechrome.vm/googlechrome.vm.nuspec +++ b/packages/googlechrome.vm/googlechrome.vm.nuspec @@ -2,11 +2,11 @@ googlechrome.vm - 0.0.0.20240405 + 0.0.0.20240425 Google LLC. Chrome is a popular web browser. - + diff --git a/packages/googlechrome.vm/tools/chocolateyinstall.ps1 b/packages/googlechrome.vm/tools/chocolateyinstall.ps1 index ebb97e19c..b01626503 100644 --- a/packages/googlechrome.vm/tools/chocolateyinstall.ps1 +++ b/packages/googlechrome.vm/tools/chocolateyinstall.ps1 @@ -22,7 +22,8 @@ try { } Install-ChocolateyInstallPackage @packageArgs -ErrorAction SilentlyContinue - VM-Assert-Path "${env:ProgramFiles}\Google\Chrome\Application\chrome.exe" + $exePath = "${env:ProgramFiles}\Google\Chrome\Application\chrome.exe" + VM-Assert-Path $exePath } catch { VM-Write-Log-Exception $_ } @@ -30,6 +31,8 @@ try { # Try to set configuration, but do not fail the package if it fails $ErrorActionPreference = 'Continue' +VM-Remove-Desktop-Shortcut "Google Chrome" + # Expand the path to the Chrome User Data folder and create the "User Data" folder if it doesn't exist. $userDataPath = ${Env:LOCALAPPDATA} + "\Google\Chrome\User Data" New-Item -ItemType Directory -Path $userDataPath -Force -ea 0 | Out-Null @@ -52,3 +55,11 @@ $contentOptions = @{ Value = "`{`"privacy_sandbox`":{`"m1`":{`"row_notice_acknowledged`":true}}`}" } Set-Content @contentOptions + +# Remove Edge from being default for file extensions so Chrome can be the default +ForEach ($hive in @("HKCU:", "HKLM:")) { + Remove-Item -Path "${hive}\SOFTWARE\Classes\MSEdgeHTM" -Recurse -ErrorAction SilentlyContinue +} + +# Make Chrome the default for .html files +VM-Set-Open-With-Association $exePath ".html"