From 928c68f47c0063852f4ab45e996c260b3612929d Mon Sep 17 00:00:00 2001 From: MyDrift Date: Thu, 8 Aug 2024 21:13:09 +0200 Subject: [PATCH] readd changes - change uninstall function call - remove winget install code - add edge install function call - remove reg keys causing cursed open with contect menu - remove edge policy keys - remove edge keys - remove edgeupdate keys - add install edg logics --- config/tweaks.json | 9 +---- .../private/Uninstall-WinUtilEdgeBrowser.ps1 | 38 +++++++++++++++++-- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/config/tweaks.json b/config/tweaks.json index 8702322f..07c17d85 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -2561,15 +2561,10 @@ "panel": "1", "Order": "a029_", "InvokeScript": [ - " - Uninstall-WinUtilEdgeBrowser - " + "Uninstall-WinUtilEdgeBrowser -action \"Uninstall\"" ], "UndoScript": [ - " - Write-Host \"Install Microsoft Edge\" - Start-Process -FilePath winget -ArgumentList \"install --force -e --accept-source-agreements --accept-package-agreements --silent Microsoft.Edge \" -NoNewWindow -Wait - " + "Uninstall-WinUtilEdgeBrowser -action \"Install\"" ], "link": "https://christitustech.github.io/winutil/dev/tweaks/z--Advanced-Tweaks---CAUTION/RemoveEdge" }, diff --git a/functions/private/Uninstall-WinUtilEdgeBrowser.ps1 b/functions/private/Uninstall-WinUtilEdgeBrowser.ps1 index 4d004f39..1f859500 100644 --- a/functions/private/Uninstall-WinUtilEdgeBrowser.ps1 +++ b/functions/private/Uninstall-WinUtilEdgeBrowser.ps1 @@ -6,6 +6,12 @@ Function Uninstall-WinUtilEdgeBrowser { This will switch up the region to one of the EEA countries temporarily and uninstall the Edge Browser (Chromium). #> + param ( + [Parameter(Mandatory = $true)] + [ValidateSet("install", "uninstall")] + [string]$action + ) + function Uninstall-EdgeClient { param ( [Parameter(Mandatory = $true)] @@ -65,6 +71,16 @@ Function Uninstall-WinUtilEdgeBrowser { [microsoft.win32.registry]::SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdateDev", "AllowUninstall", 1, [Microsoft.Win32.RegistryValueKind]::DWord) | Out-Null Uninstall-EdgeClient -Key '{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}' + + Remove-Item -Path "Computer\\HKEY_CLASSES_ROOT\\MSEdgePDF" -ErrorAction SilentlyContinue | Out-Null + Remove-Item -Path "Computer\\HKEY_CLASSES_ROOT\\MSEdgeHTM" -ErrorAction SilentlyContinue | Out-Null + Remove-Item -Path "Computer\\HKEY_CLASSES_ROOT\\MSEdgeMHT" -ErrorAction SilentlyContinue | Out-Null + + # Remove Edge Polocy reg keys + Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge" -Recurse -ErrorAction SilentlyContinue | Out-Null + + # Remove Edge reg keys + Remove-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Edge" -Recurse -ErrorAction SilentlyContinue | Out-Null } function Uninstall-WebView { @@ -93,9 +109,25 @@ Function Uninstall-WinUtilEdgeBrowser { } Start-Process cmd.exe "/c $uninstallCmdLine" -WindowStyle Hidden -Wait + + # Remove EdgeUpdate reg keys + Remove-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate" -Recurse -ErrorAction SilentlyContinue | Out-Null } - Uninstall-Edge - # Uninstall-WebView - WebView is needed for Visual Studio and some MS Store Games like Forza - Uninstall-EdgeUpdate + function Install-Edge { + $tempEdgePath = "$env:TEMP\MicrosoftEdgeSetup.exe" + + write-host "Installing Edge" + Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/?linkid=2109047&Channel=Stable&language=en&consent=1" -OutFile $tempEdgePath + Start-Process -FilePath $tempEdgePath + Remove-item $tempEdgePath + } + + if ($action -eq "Install") { + Install-Edge + } elseif ($action -eq "Uninstall") { + Uninstall-Edge + Uninstall-EdgeUpdate + # Uninstall-WebView - WebView is needed for Visual Studio and some MS Store Games like Forza + } }