Skip to content

Commit

Permalink
Make Chrome the Default for .html
Browse files Browse the repository at this point in the history
  • Loading branch information
emtuls committed Apr 26, 2024
1 parent 6f799eb commit fc6a2a5
Show file tree
Hide file tree
Showing 2 changed files with 18 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>
17 changes: 16 additions & 1 deletion packages/googlechrome.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@ 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'

# Delete Desktop shortcut created during installation
$desktopShortcut = Join-Path ${Env:Public} "Desktop\Google Chrome.lnk"
if (Test-Path $desktopShortcut) {
Remove-Item $desktopShortcut -Force -ea 0
}

# 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 +59,11 @@ $contentOptions = @{
Value = "`{`"privacy_sandbox`":{`"m1`":{`"row_notice_acknowledged`":true}}`}"
}
Set-Content @contentOptions

# Make Chrome the default for .html files
VM-Set-Open-With-Association $exePath ".html"

# 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
}

0 comments on commit fc6a2a5

Please sign in to comment.