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 13, 2024
1 parent 0f526b9 commit 2d139e7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 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.20241029</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
5 changes: 3 additions & 2 deletions packages/googlechrome.vm/googlechrome.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>googlechrome.vm</id>
<version>0.0.0.20241002</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.20240425" />
<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 2d139e7

Please sign in to comment.