Skip to content

Commit

Permalink
Set Chrome as default browser
Browse files Browse the repository at this point in the history
  • Loading branch information
emtuls committed Nov 14, 2024
1 parent 7124eb4 commit 5d86ed7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/common.vm/common.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>common.vm</id>
<version>0.0.0.20241106</version>
<version>0.0.0.20241113</version>
<description>Common libraries for VM-packages</description>
<authors>Mandiant</authors>
</metadata>
Expand Down
18 changes: 7 additions & 11 deletions packages/common.vm/tools/vm.common/vm.common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1233,33 +1233,29 @@ function VM-Update-Registry-Value {
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $name,
[string] $path,

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $path,
[string] $name,

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $value,

[Parameter(Mandatory=$true)]
[ValidateSet("String", "ExpandString", "Binary", "DWord", "QWord", "MultiString", "Unknown")]
[string] $type,

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $data
[string] $type
)

try {
# Validate the value based on the type parameter
if ($type -eq "DWord" -or $type -eq "QWord") {
$validatedData = [int64]::Parse($data)
$validatedData = [int64]::Parse($value)
} elseif ($type -eq "Binary") {
$validatedData = [byte[]]::new(($data -split '(.{2})' | Where-Object { $_ -match '..' } | ForEach-Object { [convert]::ToByte($_, 16) }))
$validatedData = [byte[]]::new(($value -split '(.{2})' | Where-Object { $_ -match '..' } | ForEach-Object { [convert]::ToByte($_, 16) }))
} else {
$validatedData = $data
$validatedData = $value
}

# check if path exists. If not, create the path for the registry value
Expand All @@ -1271,7 +1267,7 @@ function VM-Update-Registry-Value {
VM-Write-Log "WARN" "Registry key already exists: $path"
}

Set-ItemProperty -Path $path -Name $value -Value $validatedData -Type $type -Force | Out-Null
Set-ItemProperty -Path $path -Name $name -Value $validatedData -Type $type -Force | Out-Null
VM-Write-Log "INFO" "$name has been successful"
} catch {
VM-Write-Log "ERROR" "Failed to update the registry value. Error: $_"
Expand Down
6 changes: 3 additions & 3 deletions packages/googlechrome.vm/googlechrome.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>googlechrome.vm</id>
<version>0.0.0.20241106</version>
<version>0.0.0.20241113</version>
<authors>Google LLC.</authors>
<description>Chrome is a popular web browser.</description>
<dependencies>
<dependency id="common.vm" version="0.0.0.20241106" />
<dependency id="vcbuildtools.vm" />
<dependency id="common.vm" version="0.0.0.20241113" />
<dependency id="setdefaultbrowser" />
</dependencies>
</metadata>
</package>
10 changes: 8 additions & 2 deletions packages/googlechrome.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,11 @@ 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"
# Set Chrome to be the default browser
SetDefaultBrowser "chrome"

# Do not show the "Open with" popup
VM-Update-Registry-Value -path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -name "NoNewAppAlert" -value 1 -type "DWord"

# Restart Explorer.exe for registry change to take effect
Stop-Process -Name explorer -Force

0 comments on commit 5d86ed7

Please sign in to comment.