diff --git a/config/tweaks.json b/config/tweaks.json index 955b488d..b71ac304 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -586,15 +586,25 @@ }, "WPFTweaksRemoveEdge": { "Content": "Microsoft Edge - Remove", - "Description": "Unblocks Microsoft Edge uninstaller restrictions then uses that uninstaller to remove Microsoft Edge.", + "Description": "Uninstalls Microsoft Edge by creating dummy MicrosoftEdge.exe file in the legacy Edge folder. This tricks Windows into unlocking the official Edge uninstaller allowing for a system-level removal.", "category": "z__Advanced Tweaks - CAUTION", "panel": "1", "InvokeScript": [ - "Invoke-WinUtilRemoveEdge" + " + $Path = Resolve-Path -Path \"$Env:ProgramFiles (x86)\\Microsoft\\Edge\\Application\\*\\Installer\\setup.exe\" | Select-Object -Last 1 + + if (Test-Path $Path) { + New-Item -Path \"$Env:SystemRoot\\SystemApps\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\\MicrosoftEdge.exe\" -Force + Start-Process -FilePath $Path -ArgumentList \"--uninstall --system-level --force-uninstall --delete-profile\" -Wait + Write-Host \"Microsoft Edge was removed\" + } else { + Write-Host \"Microsoft Edge is not installed\" + } + " ], "UndoScript": [ " - Write-Host 'Installing Microsoft Edge...' + Write-Host \"Installing Microsoft Edge...\" winget install Microsoft.Edge --source winget " ], diff --git a/functions/public/Invoke-WinUtilRemoveEdge.ps1 b/functions/public/Invoke-WinUtilRemoveEdge.ps1 deleted file mode 100644 index b1111b21..00000000 --- a/functions/public/Invoke-WinUtilRemoveEdge.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -function Invoke-WinUtilRemoveEdge { - New-Item -Path "$Env:SystemRoot\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe" -Force - - $Path = Resolve-Path -Path "$Env:ProgramFiles (x86)\Microsoft\Edge\Application\*\Installer\setup.exe" | Select-Object -Last 1 - Start-Process -FilePath $Path -ArgumentList '--uninstall --system-level --force-uninstall --delete-profile' -Wait - - Write-Host "Microsoft Edge was removed" -ForegroundColor Green -}