From 2d139e7194ae18999caf775e6a0d6023cdeebf3b Mon Sep 17 00:00:00 2001 From: Elliot Chernofsky Date: Wed, 13 Nov 2024 16:59:42 -0500 Subject: [PATCH] Set Chrome as default browser --- packages/common.vm/common.vm.nuspec | 2 +- .../common.vm/tools/vm.common/vm.common.psm1 | 18 +++++++----------- .../googlechrome.vm/googlechrome.vm.nuspec | 5 +++-- .../tools/chocolateyinstall.ps1 | 10 ++++++++-- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/common.vm/common.vm.nuspec b/packages/common.vm/common.vm.nuspec index 8ce9e321..3566374a 100755 --- a/packages/common.vm/common.vm.nuspec +++ b/packages/common.vm/common.vm.nuspec @@ -2,7 +2,7 @@ common.vm - 0.0.0.20241029 + 0.0.0.20241113 Common libraries for VM-packages Mandiant diff --git a/packages/common.vm/tools/vm.common/vm.common.psm1 b/packages/common.vm/tools/vm.common/vm.common.psm1 index f976e6e0..5bace84a 100755 --- a/packages/common.vm/tools/vm.common/vm.common.psm1 +++ b/packages/common.vm/tools/vm.common/vm.common.psm1 @@ -1233,11 +1233,11 @@ 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()] @@ -1245,21 +1245,17 @@ function VM-Update-Registry-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 @@ -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: $_" diff --git a/packages/googlechrome.vm/googlechrome.vm.nuspec b/packages/googlechrome.vm/googlechrome.vm.nuspec index 9226cd9d..26582aae 100644 --- a/packages/googlechrome.vm/googlechrome.vm.nuspec +++ b/packages/googlechrome.vm/googlechrome.vm.nuspec @@ -2,11 +2,12 @@ googlechrome.vm - 0.0.0.20241002 + 0.0.0.20241113 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 17417158..df8271a2 100644 --- a/packages/googlechrome.vm/tools/chocolateyinstall.ps1 +++ b/packages/googlechrome.vm/tools/chocolateyinstall.ps1 @@ -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