Skip to content

Commit 273c18e

Browse files
authored
lets hope this works...
1 parent d92e51c commit 273c18e

1 file changed

Lines changed: 25 additions & 39 deletions

File tree

byebyemsedge.ps1

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,52 @@
1+
# Ensure admin permissions
12
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
2-
Write-Warning "couldnt run because you didnt run as admin."
3+
Write-Warning "run this script as an admin!"
34
Exit
45
}
56

6-
Write-Host "starting ms edge removal, this could take a while..." -ForegroundColor Cyan
7+
Write-Host "starting ms edge removal, this could take a while..."
78

8-
Write-Host "closing ms edge processes..." -ForegroundColor Yellow
9+
Write-Host "closing ms edge processes..."
910
Stop-Process -Name "msedge" -Force -ErrorAction SilentlyContinue
1011

11-
Write-Host "running forced uninstallation switch..." -ForegroundColor Yellow
12-
$edgeDir = "C:\Program Files (x86)\Microsoft\Edge\Application"
13-
if (Test-Path $edgeDir) {
14-
$installerPath = Get-ChildItem -Path $edgeDir -Filter "setup.exe" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
15-
if ($installerPath) {
16-
$installerDir = Split-Path $installerPath.FullName
17-
Start-Process -FilePath "$installerDir\setup.exe" -ArgumentList "--uninstall --system-level --verbose-logging --force-uninstall" -Wait -NoNewWindow
18-
Write-Host "core edge application files uninstalled successfully." -ForegroundColor Green
19-
} else {
20-
Write-Host "edge setup.exe not found. (you might have removed edge already.) proceeding with registry and folder cleanup." -ForegroundColor Gray
12+
Write-Host "running forced uninstallation switch..."
13+
$edgeFolder = Get-ChildItem -Path "$env:ProgramFiles(x86)\Microsoft\Edge\Application" -Filter "1*" -Directory -ErrorAction SilentlyContinue | Select-Object -First 1
14+
if ($edgeFolder) {
15+
$setupExe = Join-Path $edgeFolder.FullName "Installer\setup.exe"
16+
if (Test-Path $setupExe) {
17+
Start-Process -FilePath $setupExe -ArgumentList "--uninstall --system-level --verbose-logging --force-uninstall" -Wait -NoNewWindow
2118
}
2219
}
2320

2421
Write-Host "unregistering modern application package hooks..."
25-
# Filter out system-protected items like DevToolsClient before feeding them to Remove-AppxPackage
22+
# Safely filter packages before passing them to the removal engine
2623
Get-AppxPackage -AllUsers *MicrosoftEdge* | Where-Object { $_.NonRemovable -ne $true -and $_.PackageFullName -notlike "*DevTools*" } | ForEach-Object {
2724
try {
2825
Remove-AppxPackage -AllUsers -Package $_.PackageFullName -ErrorAction SilentlyContinue
2926
} catch {
30-
# Silent fail for locked components
27+
# Catch-all to keep the output completely clean
3128
}
3229
}
3330

34-
Write-Host "purging edge local cache, profile data, and leftovers..." -ForegroundColor Yellow
35-
$localEdgePath = "$env:LocalAppData\Microsoft\Edge"
36-
if (Test-Path $localEdgePath) {
37-
Remove-Item -Path $localEdgePath -Recurse -Force -ErrorAction SilentlyContinue
38-
Write-Host "edge local cache removed." -ForegroundColor Green
39-
}
31+
# Also handle provisioned deployment items silently
32+
Get-AppxProvisionedPackage -Online | Where-Object { $_.PackageName -like "*MicrosoftEdge*" } | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
4033

41-
$progEdgePath = "C:\Program Files (x86)\Microsoft\Edge"
42-
$progEdgeUpdatePath = "C:\Program Files (x86)\Microsoft\EdgeUpdate"
34+
Write-Host "purging edge local cache, profile data, and leftovers..."
35+
Remove-Item -Path "$env:LocalAppData\Microsoft\Edge" -Recurse -Force -ErrorAction SilentlyContinue
36+
Remove-Item -Path "$env:ProgramFiles(x86)\Microsoft\Edge" -Recurse -Force -ErrorAction SilentlyContinue
37+
Remove-Item -Path "$env:ProgramFiles(x86)\Microsoft\EdgeUpdate" -Recurse -Force -ErrorAction SilentlyContinue
38+
Write-Host "program files residues removed."
4339

44-
if (Test-Path $progEdgePath) {
45-
Remove-Item -Path $progEdgePath -Recurse -Force -ErrorAction SilentlyContinue
46-
}
47-
if (Test-Path $progEdgeUpdatePath) {
48-
Remove-Item -Path $progEdgeUpdatePath -Recurse -Force -ErrorAction SilentlyContinue
49-
}
50-
Write-Host "program files residues removed." -ForegroundColor Green
51-
52-
Write-Host "erasing ghost registry listings from settings..." -ForegroundColor Yellow
40+
Write-Host "erasing ghost registry listings from settings..."
5341
$regPaths = @(
5442
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge",
5543
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge"
5644
)
57-
58-
foreach ($regPath in $regPaths) {
59-
if (Test-Path $regPath) {
60-
Remove-Item -Path $regPath -Recurse -Force -ErrorAction SilentlyContinue
61-
Write-Host "ghost registry entries cleared from: $regPath" -ForegroundColor Green
45+
foreach ($path in $regPaths) {
46+
if (Test-Path $path) {
47+
Remove-Item -Path $path -Recurse -Force -ErrorAction SilentlyContinue
6248
}
6349
}
6450

65-
Write-Host "congratulations, the removal was a success!" -ForegroundColor Green
66-
Write-Host "a system reboot is recommended to refresh the windows settings cache, but you can do that at any time." -ForegroundColor Cyan
51+
Write-Host "congratulations, the removal was a success!"
52+
Write-Host "a system reboot is recommended to refresh the windows settings cache, but you can do that at any time."

0 commit comments

Comments
 (0)