Skip to content

Commit

Permalink
Make Chrome the Default for .html
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
emtuls authored and Ana06 committed Apr 30, 2024
1 parent cdad3c7 commit 07e548f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/googlechrome.vm/googlechrome.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>googlechrome.vm</id>
<version>0.0.0.20240405</version>
<version>0.0.0.20240425</version>
<authors>Google LLC.</authors>
<description>Chrome is a popular web browser.</description>
<dependencies>
<dependency id="common.vm" version="0.0.0.20240111" />
<dependency id="common.vm" version="0.0.0.20240425" />
</dependencies>
</metadata>
</package>
13 changes: 12 additions & 1 deletion packages/googlechrome.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ 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 $_
}

# 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
Expand All @@ -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"

0 comments on commit 07e548f

Please sign in to comment.