2024-08-06 15:39:46 -05:00
|
|
|
Function Uninstall-WinUtilEdgeBrowser {
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
2024-08-07 16:27:53 -05:00
|
|
|
Uninstall the Edge Browser (Chromium) from the system in an elegant way.
|
|
|
|
.DESCRIPTION
|
|
|
|
This will switch up the region to one of the EEA countries temporarily and uninstall the Edge Browser (Chromium).
|
2024-08-06 15:39:46 -05:00
|
|
|
#>
|
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
function Uninstall-EdgeClient {
|
|
|
|
param (
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
[string]$Key
|
|
|
|
)
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
$originalNation = [microsoft.win32.registry]::GetValue('HKEY_USERS\.DEFAULT\Control Panel\International\Geo', 'Nation', [Microsoft.Win32.RegistryValueKind]::String)
|
2024-08-06 15:50:36 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
# Set Nation to any of the EEA regions temporarily
|
|
|
|
# Refer: https://learn.microsoft.com/en-us/windows/win32/intl/table-of-geographical-locations
|
|
|
|
$tmpNation = 68 # Ireland
|
|
|
|
[microsoft.win32.registry]::SetValue('HKEY_USERS\.DEFAULT\Control Panel\International\Geo', 'Nation', $tmpNation, [Microsoft.Win32.RegistryValueKind]::String) | Out-Null
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
$baseKey = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate'
|
|
|
|
$registryPath = $baseKey + '\ClientState\' + $Key
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
if (!(Test-Path -Path $registryPath)) {
|
|
|
|
Write-Host "[$Mode] Registry key not found: $registryPath"
|
|
|
|
return
|
|
|
|
}
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
# Remove the status flag
|
|
|
|
Remove-ItemProperty -Path $baseKey -Name "IsEdgeStableUninstalled" -ErrorAction SilentlyContinue | Out-Null
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
Remove-ItemProperty -Path $registryPath -Name "experiment_control_labels" -ErrorAction SilentlyContinue | Out-Null
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
$uninstallString = (Get-ItemProperty -Path $registryPath).UninstallString
|
|
|
|
$uninstallArguments = (Get-ItemProperty -Path $registryPath).UninstallArguments
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
if ([string]::IsNullOrEmpty($uninstallString) -or [string]::IsNullOrEmpty($uninstallArguments)) {
|
|
|
|
Write-Host "[$Mode] Cannot find uninstall methods for $Mode"
|
|
|
|
return
|
|
|
|
}
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
# Extra arguments to nuke it
|
|
|
|
$uninstallArguments += " --force-uninstall --delete-profile"
|
2024-08-06 15:50:36 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
# $uninstallCommand = "`"$uninstallString`"" + $uninstallArguments
|
|
|
|
if (!(Test-Path -Path $uninstallString)) {
|
|
|
|
Write-Host "[$Mode] setup.exe not found at: $uninstallString"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
Start-Process -FilePath $uninstallString -ArgumentList $uninstallArguments -Wait -NoNewWindow -Verbose
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
# Restore Nation back to the original
|
|
|
|
[microsoft.win32.registry]::SetValue('HKEY_USERS\.DEFAULT\Control Panel\International\Geo', 'Nation', $originalNation, [Microsoft.Win32.RegistryValueKind]::String) | Out-Null
|
2024-08-06 15:50:36 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
# might not exist in some cases
|
|
|
|
if ((Get-ItemProperty -Path $baseKey).IsEdgeStableUninstalled -eq 1) {
|
|
|
|
Write-Host "[$Mode] Edge Stable has been successfully uninstalled"
|
2024-08-06 15:39:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
function Uninstall-Edge {
|
|
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" -Name "NoRemove" -ErrorAction SilentlyContinue | Out-Null
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
[microsoft.win32.registry]::SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdateDev", "AllowUninstall", 1, [Microsoft.Win32.RegistryValueKind]::DWord) | Out-Null
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
Uninstall-EdgeClient -Key '{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}'
|
|
|
|
}
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
function Uninstall-WebView {
|
|
|
|
# FIXME: might not work on some systems
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView" -Name "NoRemove" -ErrorAction SilentlyContinue | Out-Null
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
Uninstall-EdgeClient -Key '{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}'
|
2024-08-06 15:39:46 -05:00
|
|
|
}
|
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
function Uninstall-EdgeUpdate {
|
|
|
|
# FIXME: might not work on some systems
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
Remove-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update" -Name "NoRemove" -ErrorAction SilentlyContinue | Out-Null
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
$registryPath = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate'
|
|
|
|
if (!(Test-Path -Path $registryPath)) {
|
|
|
|
Write-Host "Registry key not found: $registryPath"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
$uninstallCmdLine = (Get-ItemProperty -Path $registryPath).UninstallCmdLine
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
if ([string]::IsNullOrEmpty($uninstallCmdLine)) {
|
|
|
|
Write-Host "Cannot find uninstall methods for $Mode"
|
|
|
|
return
|
|
|
|
}
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
Start-Process cmd.exe "/c $uninstallCmdLine" -WindowStyle Hidden -Wait
|
|
|
|
}
|
2024-08-06 15:39:46 -05:00
|
|
|
|
2024-08-07 16:27:53 -05:00
|
|
|
Uninstall-Edge
|
|
|
|
# Uninstall-WebView - WebView is needed for Visual Studio and some MS Store Games like Forza
|
|
|
|
Uninstall-EdgeUpdate
|
2024-08-06 15:50:36 -05:00
|
|
|
}
|