@echo off :: Check if ran as Admin net session >nul 2>&1 || (echo. & echo Run Script As Admin & echo. & pause & exit) setlocal enabledelayedexpansion :: Get user SID for /f "delims=" %%a in ('powershell "(New-Object System.Security.Principal.NTAccount($env:USERNAME)).Translate([System.Security.Principal.SecurityIdentifier]).Value"') do set "USER_SID=%%a" :: Remove Edge Appx Packages for /f "delims=" %%a in ('powershell -NoProfile -Command "Get-AppxPackage -AllUsers ^| Where-Object { $_.PackageFullName -like '*microsoftedge*' } ^| Select-Object -ExpandProperty PackageFullName"') do ( if not "%%a"=="" ( set "APP=%%a" reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife\!USER_SID!\!APP!" /f >nul 2>&1 reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\EndOfLife\S-1-5-18\!APP!" /f >nul 2>&1 reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Deprovisioned\!APP!" /f >nul 2>&1 powershell -Command "Remove-AppxPackage -Package '!APP!'" 2>nul powershell -Command "Remove-AppxPackage -Package '!APP!' -AllUsers" 2>nul ) ) endlocal