ShadowWhisperer / Remove-MS-Edge

Uninstall Microsoft Edge silently, through an executable or batch script.
2.21k stars 81 forks source link

Remove Edge UWP App [Feature Request] #10

Closed WayneSherman closed 1 year ago

WayneSherman commented 1 year ago

After removal of Edge, these packages remain installed:

Windows Appx Packages

Microsoft.MicrosoftEdge Microsoft.MicrosoftEdgeDevToolsClient

ShadowWhisperer commented 1 year ago

Does running this, remove them for you?

PowerShell.exe -Command "Get-AppxPackage -allusers *MicrosoftEdge* | Remove-AppxPackage"

WayneSherman commented 1 year ago

Does running this, remove them for you? PowerShell.exe -Command "Get-AppxPackage -allusers *MicrosoftEdge* | Remove-AppxPackage"

That doesn't work. But this technique will work: https://forums.mydigitallife.net/threads/how-to-remove-take-a-test.73177/#post-1318833

ShadowWhisperer commented 1 year ago

Try this: https://github.com/ShadowWhisperer/Internal/blob/main/App_EndOfLife.py Verbose to show what is is finding for results.

WayneSherman commented 1 year ago

This line does not return anything: Get-StartApps | Where-Object {$_.Name -like "*microsoftedge*"} | Select-Object PackageFullName from https://github.com/ShadowWhisperer/Internal/blob/94f5746cea26976233200f34fb920c3c71f953cc/App_EndOfLife.py#L18

Why Get-StartApps and not Get-AppxPackage? command = 'Get-AppxPackage -allusers | Where-Object {$_.Name -like "*microsoftedge*"} | Select-Object PackageFullName'

ionuttbara commented 1 year ago

nope. The Edge UWP (which is installed in Windows 10 1507 - 19H2 & 2xHy) it cannot be uninstalled like that. So the edge UWP its a System Package and can be uninstalled by accessing the CBS Name of that.. The Package Name of the EdgeUWP (CBS) is Microsoft-Windows-InternetBrowser-Package~~10.0.buildnumber.cumulativenumber. Uninstalling this package will be remove the Edge UWP from the system including the package, and makes updating unworkable (example old version of Windows 10, Windows 10 >20H1, and Windows 11 are fine).

ionuttbara commented 1 year ago

After applying that , you must reboot the PC.

ionuttbara commented 1 year ago

i put the .bat code, to understand what i saying: // this

for /f "tokens=8 delims=\" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" ^| findstr "Microsoft-Windows-Internet-Browser-Package" ^| findstr "~~"') do (set "edge_legacy_package_version=%%i")
if defined edge_legacy_package_version (
        echo Removing %edge_legacy_package_version%...
        reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\%edge_legacy_package_version%" /v Visibility /t REG_DWORD /d 1 /f
        reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\%edge_legacy_package_version%\Owners" /va /f
        dism /online /Remove-Package /PackageName:%edge_legacy_package_version%
    ) else (
        echo Microsoft Edge [Legacy/UWP] not found, skipping.
    )

and the EdgeDevTools Package

for /f "tokens=8 delims=\" %%i in ('reg query "
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" ^| findstr "Microsoft-Windows-MicrosoftEdgeDevToolsClient-Package" ^| findstr "~~"') do (set "melody_package_name=%%i")
if defined melody_package_name (
        echo Removing %melody_package_name%...
        reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\%melody_package_name%" /v Visibility /t REG_DWORD /d 1 /f
        reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\%melody_package_name%\Owners" /va /f
        dism /online /Remove-Package /PackageName:%melody_package_name% /NoRestart
    ) else (
        echo Edge DevTools UWP Not Found.
)

Again, first command it works of all versions of Windows including winodws 10, and windows 11 (to be sure, you must uninstall edge chromium).

Second command , depends the version of Windows which you ran.

ionuttbara commented 1 year ago

so for version 2.6 of my app i will put the c# version of commands.. to search in CBS Database of System Packages and if found to be removed.. but sometimes its not working

WayneSherman commented 1 year ago

No need for C#. Here is an example that uses "Remove-AppxPackage" along with some "dism" commands: https://github.com/AveYo/fox/blob/9d5a83142fb6a2dfd77e8e7d0ac07e8a0216942f/Edge_Removal.bat#L41 (This is a cmd/powershell hybrid. When launched via cmd it executes powershell and runs itself as a powershell script.)

In my testing, the Edge UWP packages can be removed using "Remove-AppxProvisionedPackage" and "Remove-AppxPackage" (without using "dism") if the EndOfLife registry values are set for current user SID and LocalSystem SID.

ShadowWhisperer commented 1 year ago

EndOfLife registry key has been finished and merged in with the Source and the executable.

WayneSherman commented 1 year ago

Tested latest EXE. Not all of the UWP apps are removed. Try something like this (powershell):

$UserSID = [string](Get-LocalUser -Name $env:USERNAME).SID.Value
$LocalSystemSID = "S-1-5-18"
$AppxEndOfLifeKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife"

Write-Host "Remove Edge Appx Provisioned Packages"  #Do provisioned first (fewer errors)
$EdgeApps = (Get-AppxProvisionedPackage -online) | Where-Object {$_.DisplayName -like "*microsoftedge*"}
ForEach ($App in $EdgeApps) {
  "Removing provisioned:  $($App.DisplayName)"
  New-Item "$AppxEndOfLifeKey\$UserSID\$($App.PackageName)" -Force -ErrorAction SilentlyContinue > $Null
  New-Item "$AppxEndOfLifeKey\$LocalSystemSID\$($App.PackageName)" -Force -ErrorAction SilentlyContinue > $Null
  Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName
}

Write-Host "Remove Edge Appx Packages"
$EdgeApps = (Get-AppxPackage -AllUsers).PackageFullName | Where-Object {$_ -like "*microsoftedge*"}
ForEach ($App in $EdgeApps) {
  "Removing:  $App"
  New-Item "$AppxEndOfLifeKey\$UserSID\$App" -Force -ErrorAction SilentlyContinue > $Null
  New-Item "$AppxEndOfLifeKey\$LocalSystemSID\$App" -Force -ErrorAction SilentlyContinue > $Null
  Remove-AppxPackage -Package $App
  Remove-AppxPackage -Package $App -AllUsers
}
ghost commented 1 year ago

Tested latest EXE. Not all of the UWP apps are removed. Try something like this (powershell):

$UserSID = [string](Get-LocalUser -Name $env:USERNAME).SID.Value
$LocalSystemSID = "S-1-5-18"
$AppxEndOfLifeKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife"

Write-Host "Remove Edge Appx Provisioned Packages"  #Do provisioned first (fewer errors)
$EdgeApps = (Get-AppxProvisionedPackage -online) | Where-Object {$_.DisplayName -like "*microsoftedge*"}
ForEach ($App in $EdgeApps) {
  "Removing provisioned:  $($App.DisplayName)"
  New-Item "$AppxEndOfLifeKey\$UserSID\$($App.PackageName)" -Force -ErrorAction SilentlyContinue > $Null
  New-Item "$AppxEndOfLifeKey\$LocalSystemSID\$($App.PackageName)" -Force -ErrorAction SilentlyContinue > $Null
  Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName
}

Write-Host "Remove Edge Appx Packages"
$EdgeApps = (Get-AppxPackage -AllUsers).PackageFullName | Where-Object {$_ -like "*microsoftedge*"}
ForEach ($App in $EdgeApps) {
  "Removing:  $App"
  New-Item "$AppxEndOfLifeKey\$UserSID\$App" -Force -ErrorAction SilentlyContinue > $Null
  New-Item "$AppxEndOfLifeKey\$LocalSystemSID\$App" -Force -ErrorAction SilentlyContinue > $Null
  Remove-AppxPackage -Package $App
  Remove-AppxPackage -Package $App -AllUsers
}

Thank you, this worked for removing Edge completely from Start Menu after running the regular script. Do you think you could implement this to also run on the script?

ShadowWhisperer commented 1 year ago

Appx Packages support, added