Jump to content

Recommended Posts

Posted
On 6/14/2026 at 4:02 AM, NotHereToPlayGames said:

The only "non-waste" of time way for me to compile my list is to provide it IN THE WAY THAT I USE IT.
Which in my case is from my WINREDUCER EX-100 config file.

All of the Value="5" entries below are my REMOVED services, they're not ever even installed, removed completely from my installation .iso.
The Value="4" entries below are my DISABLED services, I allow them to be installed, but they are DISABLED by default.
The Value="3" entries below are my MANUAL services.
If there is any Value="2" entries, they are AUTOMATIC services.
Any Value="1" entries, they are AUTOMATIC (DELAYED) services.
Entries with empty value fields just allow the Windows installation process to set them at normal Windows "default".

 

BUT...  there are a ton of "services" that have to be "installed" (ie, Windows Indexing/Firewall/Defender are examples), BUT I DISABLE/REMOVE THEM LATER, I just can't disable/remove beforehand.

 

You asked for a list, this is the easiest way to provide one.

  Hide contents

    <Element Category="Services" Name="ActiveX Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Agent Activation Runtime Service" Selected="true" Value="5" />
    <Element Category="Services" Name="AllJoyn Router Service" Selected="true" Value="5" />
    <Element Category="Services" Name="App Readiness Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Application Layer Gateway Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Assigned Access Manager Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Auto Time Zone Updater Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Background Intelligent Transfer Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Beep Service" Selected="true" Value="5" />
    <Element Category="Services" Name="BitLocker Drive Encryption Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Block Level Backup Engine Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Bluetooth Audio Gateway Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Bluetooth AVCTP Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Bluetooth Support Service" Selected="true" Value="5" />
    <Element Category="Services" Name="BranchCache Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Capture Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Cellular Time Service" Selected="true" Value="5" />
    <Element Category="Services" Name="COM+ Event System Service" Selected="true" Value="5" />
    <Element Category="Services" Name="COM+ System Application Service" Selected="false" Value="" />
    <Element Category="Services" Name="Computer Browser Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Connected Devices Platform Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Connected Devices Platform User Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Connected User Experiences and Telemetry" Selected="true" Value="5" />
    <Element Category="Services" Name="ConsentUX Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Contact Data Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Credential Manager Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Data Sharing Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Data Usage Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Delivery Optimization Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Device Management Enrollment Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Device Picker Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Devices Flow Service" Selected="true" Value="5" />
    <Element Category="Services" Name="DevQuery Background Discovery Broker Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Diagnostic Execution Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Diagnostic Policy Services" Selected="true" Value="5" />
    <Element Category="Services" Name="Diagnostic Service Host Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Diagnostic System Host Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Display Enhancement Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Display Policy Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Distributed Link Tracking Client Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Distributed Transaction Coordinator Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Embedded Mode Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Encrypting File System (EFS) Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Enterprise App Management Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Extensible Authentication Protocol (Eaphost) Service" Selected="false" Value="" />
    <Element Category="Services" Name="Fax Service" Selected="true" Value="5" />
    <Element Category="Services" Name="File History Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Function Discovery Provider Host Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Function Discovery Resource Publication Service" Selected="true" Value="5" />
    <Element Category="Services" Name="GameDVR and Broadcast User Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Geolocation Service" Selected="true" Value="5" />
    <Element Category="Services" Name="GPU Energy Driver Service" Selected="false" Value="" />
    <Element Category="Services" Name="Graphics Performance Service" Selected="false" Value="" />
    <Element Category="Services" Name="HomeGroup Listener and Provider Services" Selected="true" Value="5" />
    <Element Category="Services" Name="Human Interface Device (HID) Service" Selected="true" Value="5" />
    <Element Category="Services" Name="HyperV Services" Selected="true" Value="5" />
    <Element Category="Services" Name="Infrared Monitor Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Internet Connection Sharing (ICS) Service" Selected="true" Value="5" />
    <Element Category="Services" Name="IP Translation Configuration Service" Selected="true" Value="5" />
    <Element Category="Services" Name="KtmRm for Distributed Transaction Coordinator Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Link-Layer Topology Discovery Mapper Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Language Experience Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Messaging Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Microsoft Account Sign-in Assistant Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Microsoft App-V Client Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Microsoft iSCSI Initiator Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Microsoft Passport Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Microsoft Passport Container Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Natural Authentification Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Net Logon Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Network Connected Devices Auto-Setup Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Network Connection Broker Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Network Connectivity Assistant Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Offline Files Service" Selected="true" Value="5" />
    <Element Category="Services" Name="OpenSSH Authentication Agent Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Optimize Drives Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Parental Controls Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Payments and NFC Manager Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Peer Name Resolution Protocol Services" Selected="true" Value="5" />
    <Element Category="Services" Name="Phone Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Printer Support Services" Selected="true" Value="4" />
    <Element Category="Services" Name="Print Workflow Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Problem Reports and Solutions Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Program Compatibility Assistant Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Quality Windows Audio Video Experience Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Radio Management Service" Selected="false" Value="" />
    <Element Category="Services" Name="Recommended Troubleshooting Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Remote Access Auto Connection Manager Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Remote Access Manager Services" Selected="true" Value="5" />
    <Element Category="Services" Name="Remote Desktop Configuration Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Remote Desktop Services" Selected="true" Value="5" />
    <Element Category="Services" Name="Remote Desktop UserMode Port Redirector Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Remote Procedure Call (RPC) Locator" Selected="true" Value="5" />
    <Element Category="Services" Name="Remote Registry Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Routing and Remote Access Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Secondary Logon Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Security Center Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Sensor Data Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Sensor Monitoring Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Sensor Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Server Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Shared PC Account Manager Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Smart Card Services" Selected="false" Value="" />
    <Element Category="Services" Name="SNMP Trap Service" Selected="true" Value="5" />
    <Element Category="Services" Name="SSDP Discovery Service" Selected="true" Value="3" />
    <Element Category="Services" Name="Secure Socket Tunneling Protocol Service" Selected="true" Value="3" />
    <Element Category="Services" Name="Spatial Data Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Spot Verifier Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Storage Spaces Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Storage Tiers Management Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Superfetch Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Sync Host Service" Selected="true" Value="5" />
    <Element Category="Services" Name="System Event Notification Service" Selected="false" Value="" />
    <Element Category="Services" Name="TCP IP NetBIOS Helper Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Telephony Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Touch Keyboard and Handwriting Panel Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Update Orchestrator Service" Selected="true" Value="5" />
    <Element Category="Services" Name="UPnP Device Host Service" Selected="true" Value="3" />
    <Element Category="Services" Name="User Data Access Service" Selected="true" Value="3" />
    <Element Category="Services" Name="User Experience Virtualization Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Volume Shadow Copy Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Volumetric Audio Compositor Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Wallet Service" Selected="true" Value="5" />
    <Element Category="Services" Name="WAP Push Message Routing Service" Selected="true" Value="5" />
    <Element Category="Services" Name="WarpJITSvc Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Web Client Service" Selected="false" Value="" />
    <Element Category="Services" Name="Wi-Fi Direct Services Connection Manager Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Windows Backup Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Windows Biometric Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Windows Camera Frame Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Windows Connect Now Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Connection Manager Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Container Isolation Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Container Name Virtualization Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Defender Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Defender Security Center Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Defender System Guard Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Error Reporting Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Firewall Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Indexing Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Insider Program Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Media Player Network Sharing Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Windows Mobile Hotspot Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Windows Perception Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Windows Push Notifications System Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Windows Push Notifications User Service" Selected="true" Value="3" />
    <Element Category="Services" Name="Windows SMS Router Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Windows Store Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Windows Store (Install) Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Windows Store (PushToInstall) Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Windows Time Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Update Service" Selected="false" Value="" />
    <Element Category="Services" Name="Windows Update Medic Service" Selected="false" Value="" />
    <Element Category="Services" Name="WinHTTP Web Proxy Auto-Discovery Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Wired AutoConfig Service" Selected="false" Value="" />
    <Element Category="Services" Name="Workstation Service" Selected="true" Value="5" />
    <Element Category="Services" Name="WLAN AutoConfig Service" Selected="false" Value="" />
    <Element Category="Services" Name="Work Folders Service" Selected="true" Value="5" />
    <Element Category="Services" Name="WWAN AutoConfig Service" Selected="false" Value="" />
    <Element Category="Services" Name="WWAN (Local Profile Assistant) Service" Selected="false" Value="" />
    <Element Category="Services" Name="Xbox Accessory Management Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Xbox Game Monitoring Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Xbox Live Auth Manager Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Xbox Live Game Save Service" Selected="true" Value="5" />
    <Element Category="Services" Name="Xbox Live Networking Service" Selected="true" Value="5" />

Thank you for this. Perhpas its possible to turn in into a minwin list for winntsetup


Posted
18 minutes ago, ibay770 said:

Thanks for posting this. Someone made a portable edge:

https://github.com/bibicadotnet/edge-portable-chrome-next-mini

That's not the portable version that I use.  I don't have the source for mine at the moment.  I'll compare the two one of these days.

So far, I'm happy with the one that I am using.  It too has an "updater" and it too uses "chrome++" (which has never really worked 100% in any Edge variant).

And I'm not familiar with the "chrome-next-mini" enhancements that this one references.

Personally, I generally "boycott" anything that a MARKETING department gave the name of "enhancements".  :buehehe::ph34r::whistle:

Posted
22 minutes ago, ibay770 said:

Can you post a link someplace to it? Maybe pastezen?

I'll paste into a "spoiler tag" here and see if it works.  It's part of my Phase 2 process so I'll post that shortly.

Posted
2 minutes ago, NotHereToPlayGames said:

That's not the portable version that I use.  I don't have the source for mine at the moment.  I'll compare the two one of these days.

So far, I'm happy with the one that I am using.  It too has an "updater" and it too uses "chrome++" (which has never really worked 100% in any Edge variant).

And I'm not familiar with the "chrome-next-mini" enhancements that this one references.

Personally, I generally "boycott" anything that a MARKETING department gave the name of "enhancements".  :buehehe::ph34r::whistle:

Yea nothing in Microsoft works 100%,  if at all 🤣

Posted
19 minutes ago, ibay770 said:

Perhpas its possible to turn in into a minwin list for winntsetup

Possible.  But I'll let somebody else undertake that endeavor.  I prefer the WinReducer EX-100 route over the winntsetup route.

Posted

This is where my Half Baked Phase 2 dials in at, this is the first minute at startup:

48 processes, 535 threads, 14904 handles, 1.0 GB RAM (note that RAM will be higher on real hardware based on drivers for that hardware)

image.png.e2997e831f89b7a00c57e053116af14b.png

 

This is after letting it sit idle and monitoring where everything "settled" after the startup process fully completes:

46 processes, 344 threads, 14210 handles, 0.6 GB RAM

image.png.c0099b81d97b9484e1f243a042569454.png

Posted (edited)

Before:  92 processes, 693 threads, 29102 handles, 1.1 GB RAM (ie, this is a normal as-is Win10 IoT install without doing any tweaking, just running as-is [with all of the install questions set to "no"]).

After:  46 processes, 344 threads, 14210 handles, 0.6 GB RAM (the threads and handles counts is a better quantifiable measurement of "bloat" than the process count)

 

This has seemed to be a good Rule of Thumb for every version of Windows (including XP!).

A tweaked and optimized runs at *HALF* the resources when compared to a "normal as-is" install.

 

I have additional tweaks that gets me down to 34 processes!  But it (intentionally!) breaks some of Win10's GUI so those should probably be eliminated from this discussion.  :cool:

I don't even run those tweaks on my "everyday" computers, just in some VMs that were more for testing my tweaks before realizing I squeezed the turnip a little too hard for everyday use.

Edited by NotHereToPlayGames
Posted

Curious to see that script too. Not everyone always needs the gui for everything, like a kiosk for example. 

Posted (edited)

Step 1:  Disable the "Action Center".  To be honest, I've never really tracked how (or if?) the "Action Center" consumes a ton of resources or not, I just have ZERO use for it.  :whistle:

Source:  https://www.tenforums.com/tutorials/6004-enable-disable-action-center-windows-10-a.html

Obtain from above link or save the below in a <name>.reg file and double-click to add to your registry.

Windows Registry Editor Version 5.00

; Created by: Shawn Brink
; http://www.tenforums.com
; Tutorial: http://www.tenforums.com/tutorials/6004-action-center-enable-disable-windows-10-a.html


[HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\Explorer]
"DisableNotificationCenter"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Explorer]
"DisableNotificationCenter"=dword:00000001

Edited by NotHereToPlayGames
Posted (edited)

Step 2:  Disable "search indexing".  Note:  this is technically only HALF of Win10's "search" and the APP is disabled in Step 4.

Top Half Source:  copied out of one of Chris Titus Tech's scripts but I forget the actual source.
It allows me to simply right-click "Run with PowerShell" and it AUTOMATICALLY elevates to ADMIN.
Just a helluvalot easier than the way that Win10's PowerShells are normally "ran as administrator" compared to how command prompts can be "ran as administrator".

Bottom Half Source:  https://github.com/PowerShellLibrary/Hacker-Scripts/blob/master/system-setup/disable-windows-search-indexing.ps1

Save the below in a <name>.ps1 file then right-click and select Run with PowerShell.

# Force To Run As Admin
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
    Write-Output "Winutil needs to be run as Administrator. Attempting to relaunch."
    $argList = @()

    $PSBoundParameters.GetEnumerator() | ForEach-Object {
        $argList += if ($_.Value -is [switch] -and $_.Value) {
            "-$($_.Key)"
        } elseif ($_.Value -is [array]) {
            "-$($_.Key) $($_.Value -join ',')"
        } elseif ($_.Value) {
            "-$($_.Key) '$($_.Value)'"
        }
    }

    $script = if ($PSCommandPath) {
        "& { & `'$($PSCommandPath)`' $($argList -join ' ') }"
    } else {
        "&([ScriptBlock]::Create((irm https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1))) $($argList -join ' ')"
    }

    $powershellCmd = if (Get-Command pwsh -ErrorAction SilentlyContinue) { "pwsh" } else { "powershell" }
    $processCmd = if (Get-Command wt.exe -ErrorAction SilentlyContinue) { "wt.exe" } else { "$powershellCmd" }

    if ($processCmd -eq "wt.exe") {
        Start-Process $processCmd -ArgumentList "$powershellCmd -ExecutionPolicy Bypass -NoProfile -Command `"$script`"" -Verb RunAs
    } else {
        Start-Process $processCmd -ArgumentList "-ExecutionPolicy Bypass -NoProfile -Command `"$script`"" -Verb RunAs
    }

    break
}


# Disable Search
Get-Service -Name "*WSearch*" | Set-Service -StartupType Disabled
Get-Service -Name "*WSearch*" | Stop-Service

Edited by NotHereToPlayGames
Posted (edited)

Step 3:  Remove "Get Started", "Windows Backup", and "Edge".

Forum software kept "double-indenting" when posting as a "spoiler" so I had to post as a "code inside a spoiler" instead.

Source:  forgot, it's two or three scripts all merged into one and edited to REMOVE where the original author threw in Firefox BS, will add after I reinvent that wheel.

Save the below in a <name>.ps1 file then right-click and select Run with PowerShell.

 
#:: REMOVE GET STARTED AND WINDOWS BACKUP
Param(     [Parameter(ValueFromPipelineByPropertyName)]$RemoveStartMenuItems = $True,
        [Parameter(ValueFromPipelineByPropertyName)]$RestartExplorer = $True )
	Function Restart-Explorer
{
    $szExplorerBinName = "explorer.exe"
    $szSystem32Path = [Environment]::GetFolderPath( "System" )
    $szTaskKillBinary = "$szSystem32Path\taskkill.exe"
    Write-Host -ForegroundColor White "Killing the process '$szExplorerBinName'..."
    Start-Process -WindowStyle Hidden -Wait -FilePath $szTaskKillBinary -ArgumentList "/F /IM $szExplorerBinName"
    Write-Host -ForegroundColor White "Starting the process '$szExplorerBinName'..."
    Start-Process -WindowStyle Hidden -FilePath "cmd" -ArgumentList "/c start /wait $szExplorerBinName"
    $szNameWithoutExtension = [io.path]::GetFilenameWithoutExtension( $szExplorerBinName )
    Write-Host -ForegroundColor White "Waiting for the process '$szNameWithoutExtension' to start..."
    $iCount = 0
    While ( ((Get-Process -Name $szNameWithoutExtension -ErrorAction SilentlyContinue).Count -Eq 0) -And ($iCount -lt $Timeout) )
    {
        Start-Sleep -Seconds 1
        $iCount++
    }
}
	Function Get-UserNameFromSID
{
    Param (    [Parameter(ValueFromPipelineByPropertyName)]$SID = "" )
    $objSID = New-Object System.Security.Principal.SecurityIdentifier( $SID ) 
    $objUser = $objSID.Translate( [System.Security.Principal.NTAccount] ) 
    Return $objUser.Value 
}
	Function Remove-NonRemovablePackage
{
    Param(     [Parameter(ValueFromPipelineByPropertyName)]$Name )
    Process
    {
        $bRet = $False
        Write-Host -ForegroundColor White "Getting details for package '$Name'..."
        $objAppx = Get-AppxPackage -AllUsers -Name $Name
        If ( $Null -Ne $objAppx )
        {
            If ( $objAppx.Count -Gt 1 ) { $objAppx = $objAppx[0] }
            $aszUserSIDs = @()
            $aszUserSIDs += $((Get-AppxPackage -AllUsers -Name $objAppx.Name).PackageUserInformation.UserSecurityId.Sid)
            $szStoreRegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore"
            Write-Host -ForegroundColor White "Setting package '$($objAppx.PackageFamilyName)' to deprovisioned..."
            $objDeprovisionedRegKey = New-Item -Force -Path "$szStoreRegKey\Deprovisioned\$($objAppx.PackageFamilyName)"
            Write-Host -ForegroundColor White "Setting the End-of-life setting for package '$($objAppx.PackageFullName)'..."
            ForEach ( $szUserSID in $aszUserSIDs )
            {
                $objEOLPkgRegKey = New-Item -Force -Path "$szStoreRegKey\EndOfLife\$szUserSID\$($objAppx.PackageFullName)"
            }
            Write-Host -ForegroundColor White "Removing package '$($objAppx.PackageFullName)' for all users..."
            Remove-AppxPackage -AllUsers -Package $($objAppx.PackageFullName)
            $bRet = $True
            $objCheckAppx = Get-AppxPackage -AllUsers -Name $objAppx.Name
            If ( $Null -Ne $objCheckAppx )
            {
                ForEach ( $objUser in $objCheckAppx.PackageUserInformation )
                {
                    If ( $objUser.UserSecurityId.Sid -Ne "S-1-5-18" )
                    {
                        $szCheckUserName = Get-UserNameFromSID -SID $objUser.UserSecurityId.Sid
                        Write-Host -ForegroundColor Yellow "WARNING: Unable to remove package for user '$szCheckUserName' ($($objUser.UserSecurityId.Sid)) with state '$($objUser.InstallState)'."
                    }
                }
            }
            Write-Host -ForegroundColor White "Removing the End-of-life setting for package '$($objAppx.PackageFullName)'..."
            ForEach ( $szUserSID in $aszUserSIDs )
            {
                Remove-Item -Force -Recurse -Path "$szStoreRegKey\EndOfLife\$szUserSID\$($objAppx.PackageFullName)" -ErrorAction SilentlyContinue
                Remove-Item -Force -Recurse -Path "$szStoreRegKey\Deleted\EndOfLife\$szUserSID\$($objAppx.PackageFullName)" -ErrorAction SilentlyContinue
            }
            Write-Host -ForegroundColor White "Removing the deprovisioned setting for package '$($objAppx.PackageFamilyName)'..."
            Remove-Item -Force -Recurse -Path "$szStoreRegKey\Deprovisioned\$($objAppx.PackageFamilyName)"
        }
        Else
        {
            Write-Host -ForegroundColor Red "ERROR: No package found called '$Name'."
        }
        Return $bRet
    }
}
	Function Set-FilePathAdminsFullControl
{
    Param(    [Parameter(ValueFromPipelineByPropertyName)]$FilePath )
    Process
    {
        $szUser = "Administrators"
        $aclOrig = Get-Acl $FilePath
        $aclPath = Get-Acl $FilePath
        Write-Host -ForegroundColor White "Setting '$szUser' to have full control of '$FilePath'..."
        $arPath = New-Object System.Security.AccessControl.FileSystemAccessRule( $szUser, "FullControl", $([System.Security.AccessControl.InheritanceFlags]::None), "None", "Allow" )
        $aclPath.SetAccessRule( $arPath )
        Set-Acl $FilePath $aclPath
        Return $aclOrig
    }
}
	Function Reset-FilePathACL
{
    Param(    [Parameter(ValueFromPipelineByPropertyName)]$FilePath,
            [Parameter(ValueFromPipelineByPropertyName)]$ACL )
    Process
    {
        Write-Host -ForegroundColor White "Resetting permissions on '$FilePath'..."
        Set-Acl $FilePath $ACL
    }
}
	Function Hide-StartMenuItem
{
    Param(    [Parameter(ValueFromPipelineByPropertyName)]$Name,
            [Parameter(ValueFromPipelineByPropertyName)]$DisplayName,
            [Parameter(ValueFromPipelineByPropertyName)]$XML )
    Process
    {
        $xmlNode = $XML.Package.Applications.Application | Where-Object { $_.Id -Eq $Name }
        If ( $xmlNode.VisualElements )
        {
            $szAppListEntryValue = $xmlNode.VisualElements.GetAttribute( "AppListEntry" )
            If ( $szAppListEntryValue -Ne "none" )
            {
                Write-Host -ForegroundColor White "Hiding the Start menu item '$DisplayName'..."
                $xmlNode.VisualElements.SetAttribute( "AppListEntry", "none" )
            }
            Else
            {
                Write-Host -ForegroundColor White "The Start menu item '$DisplayName' is already hidden."
            }
        }
    }
}
	Function Get-XMLAttribute
{
    Param(    [Parameter(ValueFromPipelineByPropertyName)]$Name,
            [Parameter(ValueFromPipelineByPropertyName)]$Attribute,
            [Parameter(ValueFromPipelineByPropertyName)]$XML,
            [Parameter(ValueFromPipelineByPropertyName)]$ShowError )
    Process
    {
        $szAttributeValue = ""
        $xmlNode = $XML | Where-Object { $_.Name -Eq $Name }
        If ( $xmlNode )
        {
            $szAttributeValue = $xmlNode.GetAttribute( $Attribute )
        }
        ElseIf ( $ShowError )
        {
            Write-Host -ForegroundColor Red "ERROR: Failed to find the attribute '$Attribute' for '$Name'."
        }
        Return $szAttributeValue, $xmlNode
    }
}
	Function Get-ScriptName
{
    $szScriptName = [System.IO.Path]::GetFileNameWithoutExtension( $(Split-Path $MyInvocation.PSCommandPath -Leaf) )
    Return $szScriptName
}
	Function Increment-PackageVersion
{
    Param(    [Parameter(ValueFromPipelineByPropertyName)]$Name,
            [Parameter(ValueFromPipelineByPropertyName)]$Attribute,
            [Parameter(ValueFromPipelineByPropertyName)]$XML )
    Process
    {
        $szNewPackageVersion = ""
        $szPackageVersion, $xmlNode = Get-XMLAttribute -Name $Name -Attribute $Attribute -XML $XML -ShowError:$True
        If ( ($szPackageVersion -Ne "") -And ($Null -Ne $xmlNode) )
        {
            $szNewPackageVersion = "$(([System.Version]$szPackageVersion).Major).$(([System.Version]$szPackageVersion).Minor).$(([System.Version]$szPackageVersion).Build).$(([System.Version]$szPackageVersion).Revision+1)"
            Write-Host -ForegroundColor White "Changing package '$Name' version from '$szPackageVersion' to '$szNewPackageVersion'..."
            $xmlNode.SetAttribute( "Version", $szNewPackageVersion )
        }
        Return $szNewPackageVersion
    }
}
	Function Save-XMLFile
{
    Param(    [Parameter(ValueFromPipelineByPropertyName)]$Name,
            [Parameter(ValueFromPipelineByPropertyName)]$Path,
            [Parameter(ValueFromPipelineByPropertyName)]$XML )
    Process
    {
        Write-Host -ForegroundColor White "Saving the updated Appx manifest file for '$Name'..."
        $objUTF8WithoutBOM = New-Object System.Text.UTF8Encoding( $False )
        $objUTF8WithoutBOMSW = New-Object System.IO.StreamWriter( $Path, $False, $objUTF8WithoutBOM )
        $XML.Save( $objUTF8WithoutBOMSW )
        $objUTF8WithoutBOMSW.Close()
    }
}
	Function Remove-StartMenuCBSItems
{
    Param( [Parameter(ValueFromPipelineByPropertyName)]$RestartExplorer )
    Process
    {
        $szCBSName = "MicrosoftWindows.Client.CBS"
        $szCBSAppName = "$($szCBSName)_cw5n1h2txyewy"
        $szWindowsPath = [Environment]::GetFolderPath( "Windows" )
        $szCBSXMLPath = "$szWindowsPath\SystemApps\$($szCBSAppName)\appxmanifest.xml"
        Write-Host -ForegroundColor White "Reading the Appx manifest file for '$szCBSAppName'..."
        $xmlCBS = [XML]( Get-Content $szCBSXMLPath )
        $szCBSNewVersion = Increment-PackageVersion -Name $szCBSName -Attribute "Version" -XML ($xmlCBS.Package.Identity)
        If ( $szCBSNewVersion -Eq "" ) { Return }
        $szCBSDesc = $xmlCBS.Package.Properties.Description
        If ( ($Null -Eq $szCBSDesc) -Or !($szCBSDesc.StartsWith($(Get-ScriptName))) )
        {
            $szOrigCBSVersion = $szCBSVersion
            $objDescElement = $xmlCBS.CreateElement( "Description", $xmlCBS.Package.Properties.NamespaceURI )
            $objDescElement.InnerText = "$(Get-ScriptName)_$szOrigCBSVersion"
            $xmlCBSNode = $xmlCBS.Package.Properties.AppendChild( $objDescElement )
        }
        Else
        {
            $szOrigCBSVersion = $szCBSDesc.Replace( "$(Get-ScriptName)_", "" )
        }
        Hide-StartMenuItem -Name "WebExperienceHost" -DisplayName "Get Started" -XML $xmlCBS
        Hide-StartMenuItem -Name "WindowsBackup" -DisplayName "Windows Back up" -XML $xmlCBS
        Hide-StartMenuItem -Name "CrossDeviceResumeApp" -DisplayName "Continue from Phone" -XML $xmlCBS
        $szOrigBackFilePath = "$($szCBSXMLPath)_$($szOrigCBSVersion)_original.xml"
        If ( !(Test-Path -Path $szOrigBackFilePath) )
        {
            Write-Host -ForegroundColor White "Creating a backup of the original Appx manifest file for '$szCBSAppName'..."
            Copy-Item -Force -Path $szCBSXMLPath -Destination $szOrigBackFilePath
        }
        Else
        {
            Write-Host -ForegroundColor White "Creating a backup of the current Appx manifest file for '$szCBSAppName'..."
            $szCurrentTime = (Get-Date).ToString( "yyyy-MM-dd_HH-mm-ss" )
            Copy-Item -Force -Path $szCBSXMLPath -Destination "$($szCBSXMLPath)_$($szOrigCBSVersion)_$($szCurrentTime).xml"
        }
        $aclOrigCBSXML = Set-FilePathAdminsFullControl -FilePath $szCBSXMLPath
        Save-XMLFile -Name $szCBSAppName -Path $szCBSXMLPath -XML $xmlCBS
        $bRemoved = Remove-NonRemovablePackage -Name $szCBSName
        Write-Host -ForegroundColor White "Installing package '$szCBSName' for all users..."
        Get-AppxPackage -AllUsers -Name $szCBSName | ForEach {Add-AppxPackage -ForceApplicationShutdown -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
        Write-Host -ForegroundColor White "Waiting a second..."
        Start-Sleep -Seconds 1
        If ( $RestartExplorer ) { Restart-Explorer }
        Reset-FilePathACL -FilePath $szCBSXMLPath -ACL $aclOrigCBSXML
    }
}
	Function Restore-StartMenuCBSItems
{
    Param( [Parameter(ValueFromPipelineByPropertyName)]$RestartExplorer )
    Process
    {
        $szWindowsPath = [Environment]::GetFolderPath( "Windows" )
        $szCBSName = "MicrosoftWindows.Client.CBS"
        $szCBSAppName = "$($szCBSName)_cw5n1h2txyewy"
        $szCBSAppPath = "$szWindowsPath\SystemApps\$($szCBSAppName)"
        $szCBSXMLPath = "$szCBSAppPath\appxmanifest.xml"
        $szOrigCBSVersion = ""
        $szScriptName = Get-ScriptName
        Write-Host -ForegroundColor White "Reading the Appx manifest file for '$szCBSAppName'..."
        $xmlCBS = [XML]( Get-Content $szCBSXMLPath )
        $szCBSDesc = $xmlCBS.Package.Properties.Description
        If ( ($Null -Eq $szCBSDesc) -Or !($szCBSDesc.StartsWith("$($szScriptName)_")) )
        {
            Write-Host -ForegroundColor Yellow "The original version of the package '$szCBSAppName' is currently installed. Taking no action."
            Return
        }
        Else
        {
            $szOrigCBSVersion = $szCBSDesc.Replace( "$($szScriptName)_", "" )
        }
        $szOrigBackFilePath = "$($szCBSXMLPath)_$($szOrigCBSVersion)_original.xml"
        $bRemoved = Remove-NonRemovablePackage -Name $szCBSName
        If ( Test-Path -Path $szOrigBackFilePath )
        {
            $szCBSNewVersion = Increment-PackageVersion -Name $szCBSName -Attribute "Version" -XML ($xmlCBS.Package.Identity)
            $xmlOrigCBS = [XML]( Get-Content $szOrigBackFilePath )
            $xmlOrigCBS.Package.Identity.SetAttribute( "Version", $szCBSNewVersion )
            Save-XMLFile -Name $szCBSAppName -Path $szOrigBackFilePath -XML $xmlOrigCBS
            $aclOrigCBSXML = Set-FilePathAdminsFullControl -FilePath $szCBSXMLPath
            Write-Host -ForegroundColor White "Restoring the original AppX manifest file for '$szCBSAppName' (with a incremented revision number)..."
            Move-Item -Force -Path $szOrigBackFilePath -Destination $szCBSXMLPath
            Reset-FilePathACL -FilePath $szCBSXMLPath -ACL $aclOrigCBSXML
        }
        $aBackupFiles = Get-ChildItem "$szCBSAppPath\*" -Include "appxmanifest.xml_*.xml"
        If ( $Null -Ne $aBackupFiles )
        {
            Write-Host -ForegroundColor White "Removing backups of the Appx manifest file for '$szCBSAppName'..."
            $aBackupFiles | Remove-Item
        }
        Write-Host -ForegroundColor White "Installing package '$szCBSName' for all users..."
        Get-AppxPackage -AllUsers -Name $szCBSName | ForEach {Add-AppxPackage -ForceApplicationShutdown -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
        If ( $RestartExplorer ) { Restart-Explorer }
    }
}
	If ( $RemoveStartMenuItems )
{
    Remove-StartMenuCBSItems -RestartExplorer:$RestartExplorer
}
Else
{
    Restore-StartMenuCBSItems -RestartExplorer:$RestartExplorer
}
	# This is modified when upgrading from M.n.b.0 to M.n.b.1:
# "C:\Windows\WinSxS\amd64_userexperience-desktop_31bf3856ad364e35_10.0.26100.4061_none_c848fbef1a2b2498\CBS\appxmanifest.xml"
	#:: REMOVE EDGE
@(set "0=%~f0"^)#) & powershell -nop -c iex([io.file]::ReadAllText($env:0)) & exit /b
#:: just copy-paste into powershell - it's a standalone hybrid script
sp 'HKCU:\Volatile Environment' 'Edge_Removal' @'
	$also_remove_webview = 1
## why also remove webview? because it is 2 copies of edge, not a slimmed down CEF, and is driving bloated web apps
$also_remove_widgets = 1
## why also remove widgets? because it is a webview glorified ad portal on msn and bing news cathering to stupid people
$also_remove_xsocial = 1
## why also remove xsocial? because it starts webview setup every boot - xbox gamebar will still work without the social crap
	$host.ui.RawUI.WindowTitle = 'Edge Removal - AveYo, 2023.09.14'
write-host "Run the script again whenever you need to reinstall and update edge or webview..`n"
$remove_appx = @("MicrosoftEdge"); $remove_win32 = @("Microsoft Edge","Microsoft Edge Update"); $skip = @() # @("DevTools")
if ($also_remove_webview -eq 1) {$remove_appx += "Win32WebViewHost"; $remove_win32 += "Microsoft EdgeWebView"}
if ($also_remove_widgets -eq 1) {$remove_appx += "WebExperience"}
if ($also_remove_xsocial -eq 1) {$remove_appx += "GamingServices"}
	$global:WEBV = $also_remove_webview -eq 1
$global:IS64 = [Environment]::Is64BitOperatingSystem
$global:IFEO = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options'
$global:EDGE_UID = '{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}'
$global:WEBV_UID = '{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}'
$global:UPDT_UID = '{F3C4FE00-EFD5-403B-9569-398A20F1BA4A}'
$global:PROGRAMS = ($env:ProgramFiles, ${env:ProgramFiles(x86)})[$IS64]
$global:SOFTWARE = ('SOFTWARE', 'SOFTWARE\WOW6432Node')[$IS64]
$global:ALLHIVES = 'HKCU:\SOFTWARE','HKLM:\SOFTWARE','HKCU:\SOFTWARE\Policies','HKLM:\SOFTWARE\Policies'
if ($IS64) { $global:ALLHIVES += "HKCU:\$SOFTWARE","HKLM:\$SOFTWARE","HKCU:\$SOFTWARE\Policies","HKLM:\$SOFTWARE\Policies"}
## -------------------------------------------------------------------------------------------------------------------------------
	## 1 bonus! enter into powershell console: firefox / edge / webview to install a browser / reinstall edge / webview after removal
function global:firefox { $url = 'https://download.mozilla.org/?product=firefox-stub'
  $setup = "$((new-object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path)\Firefox Installer.exe"
  write-host $url; Invoke-WebRequest $url -OutFile $setup; start $setup
}
function global:edge { $url = 'https://go.microsoft.com/fwlink/?linkid=2108834&Channel=Stable&language=en'
  $setup = "$((new-object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path)\MicrosoftEdgeSetup.exe"
  write-host $url; Invoke-WebRequest $url -OutFile $setup; PREPARE_EDGE; start $setup
}
function global:webview { $url = 'https://go.microsoft.com/fwlink/p/?LinkId=2124703'
  $setup = "$((new-object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path)\MicrosoftEdgeWebview2Setup.exe"
  write-host $url; Invoke-WebRequest $url -OutFile $setup; PREPARE_WEBVIEW; start $setup
}
function global:xsocial { $url = 'https://dlassets-ssl.xboxlive.com/public/content/XboxInstaller/XboxInstaller.exe'
  $setup = "$((new-object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path)\XboxInstaller.exe"
  write-host $url; Invoke-WebRequest $url -OutFile $setup; PREPARE_WEBVIEW; start $setup
}
	## helper for set-itemproperty remove-itemproperty new-item remove-item with auto test-path
function global:sp_test_path { if (test-path $args[0]) {Microsoft.PowerShell.Management\Set-ItemProperty @args} else {
  Microsoft.PowerShell.Management\New-Item $args[0] -force -ea 0 >''; Microsoft.PowerShell.Management\Set-ItemProperty @args} }
function global:rp_test_path { if (test-path $args[0]) {Microsoft.PowerShell.Management\Remove-ItemProperty @args} }
function global:ni_test_path { if (-not (test-path $args[0])) {Microsoft.PowerShell.Management\New-Item @args} }
function global:ri_test_path { if (test-path $args[0]) {Microsoft.PowerShell.Management\Remove-Item @args} }
foreach ($f in 'sp','rp','ni','ri') {set-alias -Name $f -Value "${f}_test_path" -Scope Local -Option AllScope -force -ea 0}
	## helper for edgeupdate reinstall
function global:PREPARE_UPDT($cdp='msedgeupdate', $uid=$UPDT_UID) {
  foreach ($f in 'sp','rp','ni','ri') {set-alias -Name $f -Value "${f}_test_path" -Scope Local -Option AllScope -force -ea 0}
  foreach ($sw in $ALLHIVES) { 
    rp "$sw\Microsoft\EdgeUpdate" 'DoNotUpdateToEdgeWithChromium' -force -ea 0
    rp "$sw\Microsoft\EdgeUpdate" 'UpdaterExperimentationAndConfigurationServiceControl' -force -ea 0
    rp "$sw\Microsoft\EdgeUpdate" "InstallDefault" -force -ea 0
    rp "$sw\Microsoft\EdgeUpdate" "Install${uid}" -force -ea 0
    rp "$sw\Microsoft\EdgeUpdate" "EdgePreview${uid}" -force -ea 0
    rp "$sw\Microsoft\EdgeUpdate" "Update${uid}" -force -ea 0
    rp "$sw\Microsoft\EdgeUpdate\ClientState\*" 'experiment_control_labels' -force -ea 0 
    ri "$sw\Microsoft\EdgeUpdate\Clients\${uid}\Commands" -recurse -force -ea 0
    rp "$sw\Microsoft\EdgeUpdateDev\CdpNames" "$cdp-*" -force -ea 0
    sp "$sw\Microsoft\EdgeUpdateDev" 'CanContinueWithMissingUpdate' 1 -type Dword -force
    sp "$sw\Microsoft\EdgeUpdateDev" 'AllowUninstall' 1 -type Dword -force
  }
}
## helper for edge reinstall - remove bundled OpenWebSearch redirector and edgeupdate policies
function global:PREPARE_EDGE {
  foreach ($f in 'sp','rp','ni','ri') {set-alias -Name $f -Value "${f}_test_path" -Scope Local -Option AllScope -force -ea 0}
  PREPARE_UPDT 'msedge' $EDGE_UID; PREPARE_UPDT 'msedgeupdate' $UPDT_UID 
  $MSEDGE = "$PROGRAMS\Microsoft\Edge\Application\msedge.exe"
  ri "$IFEO\msedge.exe" -recurse -force; ri "$IFEO\ie_to_edge_stub.exe" -recurse -force
  ri 'Registry::HKEY_Users\S-1-5-21*\Software\Classes\microsoft-edge' -recurse -force
  sp 'HKLM:\SOFTWARE\Classes\microsoft-edge\shell\open\command' '(Default)' "`"$MSEDGE`" --single-argument %%1" -force
  ri 'Registry::HKEY_Users\S-1-5-21*\Software\Classes\MSEdgeHTM' -recurse -force
  sp 'HKLM:\SOFTWARE\Classes\MSEdgeHTM\shell\open\command' '(Default)' "`"$MSEDGE`" --single-argument %%1" -force
}
## helper for webview reinstall - restore webexperience (widgets) if available
function global:PREPARE_WEBVIEW {
  PREPARE_UPDT 'msedgewebview' $WEBV_UID; PREPARE_UPDT 'msedgeupdate' $UPDT_UID
  $cfg = @{Register=$true; ForceApplicationShutdown=$true; ForceUpdateFromAnyVersion=$true; DisableDevelopmentMode=$true} 
  dir "$env:SystemRoot\SystemApps\Microsoft.Win32WebViewHost*\AppxManifest.xml" -rec -ea 0 | Add-AppxPackage @cfg
  dir "$env:ProgramFiles\WindowsApps\MicrosoftWindows.Client.WebExperience*\AppxManifest.xml" -rec -ea 0 | Add-AppxPackage @cfg
  kill -name explorer -ea 0; if ((get-process -name 'explorer' -ea 0) -eq $null) {start explorer}
}
## -------------------------------------------------------------------------------------------------------------------------------
	## 2 enable admin privileges
$D1=[uri].module.gettype('System.Diagnostics.Process')."GetM`ethods"(42) |where {$_.Name -eq 'SetPrivilege'} #`:no-ev-warn
'SeSecurityPrivilege','SeTakeOwnershipPrivilege','SeBackupPrivilege','SeRestorePrivilege'|foreach {$D1.Invoke($null, @("$_",2))}
## -------------------------------------------------------------------------------------------------------------------------------
	## 3 shut down edge & webview clone stuff
cd $env:systemdrive; taskkill /im explorer.exe /f 2>&1 >''
$shut = 'explorer','Widgets','widgetservice','msedgewebview2','MicrosoftEdge*','chredge','msedge','edge'
$shut,'msteams','msfamily','WebViewHost','Clipchamp' |foreach {kill -name $_ -force -ea 0}
	## clear win32 uninstall block
foreach ($name in $remove_win32) { foreach ($sw in $ALLHIVES) {
  $key = "$sw\Microsoft\Windows\CurrentVersion\Uninstall\$name"; if (-not (test-path $key)) {continue}
  foreach ($val in 'NoRemove','NoModify','NoRepair') {rp $key $val -force -ea 0}
  foreach ($val in 'ForceRemove','Delete') {sp $key $val 1 -type Dword -force}
}}
PREPARE_EDGE
	## find all Edge setup.exe and gather BHO paths for OpenWebSearch / MSEdgeRedirect usage
$edges = @(); $bho = @(); $edgeupdates = @(); 'LocalApplicationData','ProgramFilesX86','ProgramFiles' |foreach {
  $folder = [Environment]::GetFolderPath($_); $bho += dir "$folder\Microsoft\Edge*\ie_to_edge_stub.exe" -rec -ea 0
  if ($WEBV) {$edges += dir "$folder\Microsoft\Edge*\setup.exe" -rec -ea 0 |where {$_ -like '*EdgeWebView*'}}
  $edges += dir "$folder\Microsoft\Edge*\setup.exe" -rec -ea 0 |where {$_ -notlike '*EdgeWebView*'}
  $edgeupdates += dir "$folder\Microsoft\EdgeUpdate\*.*.*.*\MicrosoftEdgeUpdate.exe" -rec -ea 0
}
	## export OpenWebSearch innovative redirector - used by MSEdgeRedirect as well
$DIR = "$env:SystemDrive\Scripts"; mkdir $DIR -ea 0 >''
foreach ($b in $bho) { if (test-path $b) { try {copy $b "$DIR\ie_to_edge_stub.exe" -force -ea 0} catch{} } }
## -------------------------------------------------------------------------------------------------------------------------------
	## 4 remove found *Edge* appx packages with unblock tricks
$provisioned = get-appxprovisionedpackage -online; $appxpackage = get-appxpackage -allusers; $eol = @()
$store = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore'
$users = @('S-1-5-18'); if (test-path $store) {$users += $((dir $store -ea 0 |where {$_ -like '*S-1-5-21*'}).PSChildName)}
foreach ($choice in $remove_appx) { if ('' -eq $choice.Trim()) {continue}
  foreach ($appx in $($provisioned |where {$_.PackageName -like "*$choice*"})) {
    $next = !1; foreach ($no in $skip) {if ($appx.PackageName -like "*$no*") {$next = !0}} ; if ($next) {continue}
    $PackageName = $appx.PackageName; $PackageFamilyName = ($appxpackage |where {$_.Name -eq $appx.DisplayName}).PackageFamilyName 
    ni "$store\Deprovisioned\$PackageFamilyName" -force >''; $PackageFamilyName  
    foreach ($sid in $users) {ni "$store\EndOfLife\$sid\$PackageName" -force >''} ; $eol += $PackageName
    dism /online /set-nonremovableapppolicy /packagefamily:$PackageFamilyName /nonremovable:0 >''
    remove-appxprovisionedpackage -packagename $PackageName -online -allusers >''
  }
  foreach ($appx in $($appxpackage |where {$_.PackageFullName -like "*$choice*"})) {
    $next = !1; foreach ($no in $skip) {if ($appx.PackageFullName -like "*$no*") {$next = !0}} ; if ($next) {continue}
    $PackageFullName = $appx.PackageFullName; 
    ni "$store\Deprovisioned\$appx.PackageFamilyName" -force >''; $PackageFullName
    foreach ($sid in $users) {ni "$store\EndOfLife\$sid\$PackageFullName" -force >''} ; $eol += $PackageFullName
    dism /online /set-nonremovableapppolicy /packagefamily:$PackageFamilyName /nonremovable:0 >''
    remove-appxpackage -package $PackageFullName -allusers >''
  }
}
## -------------------------------------------------------------------------------------------------------------------------------
	## 5 run found *Edge* setup.exe with uninstall args and wait in-between
foreach ($setup in $edges) { if (-not (test-path $setup)) {continue}
  if ($setup -like '*EdgeWebView*') {$target = "--msedgewebview"} else {$target = "--msedge"}
  $sulevel = ('--system-level','--user-level')[$setup -like '*\AppData\Local\*']
  $removal = "--uninstall $target $sulevel --verbose-logging --force-uninstall"
  try {write-host $setup $removal; start -wait $setup -args $removal} catch {}
  do {sleep 3} while ((get-process -name 'setup','MicrosoftEdge*' -ea 0).Path -like '*\Microsoft\Edge*')
}
## -------------------------------------------------------------------------------------------------------------------------------
	## msi installers cleanup
gp 'HKLM:\SOFTWARE\Classes\Installer\Products\*' 'ProductName' |where {$_.ProductName -like '*Microsoft Edge*'} |foreach { 
  $prod = ($_.PSChildName -split '(.{8})(.{4})(.{4})(.{4})' -join '-').trim('-')
  $sort = 7,6,5,4,3,2,1,0,8,12,11,10,9,13,17,16,15,14,18,20,19,22,21,23,25,24,27,26,29,28,31,30,33,32,35,34
  $code = '{' + -join ($sort |foreach {$prod[$_]}) + '}'; start -wait msiexec.exe -args "/X$code /qn" 2>''
  ri $_.PSPath -recurse -force
  foreach ($sw in $ALLHIVES) {ri "$sw\Microsoft\Windows\CurrentVersion\Uninstall\$code" -recurse -force}  
} 
	## 6 edgeupdate graceful cleanup
if ($WEBV) {
  foreach ($sw in $ALLHIVES) {ri "$sw\Microsoft\EdgeUpdate" -recurse -force}  
  foreach ($UPDT in $edgeupdates) { 
    if (test-path $UPDT) {write-host "$UPDT /unregsvc";  start -wait $UPDT -args '/unregsvc'}
    do {sleep 3} while ((get-process -name 'setup','MicrosoftEdge*' -ea 0).Path -like '*\Microsoft\Edge*')
    if (test-path $UPDT) {write-host "$UPDT /uninstall"; start -wait $UPDT -args '/uninstall'}
    do {sleep 3} while ((get-process -name 'setup','MicrosoftEdge*' -ea 0).Path -like '*\Microsoft\Edge*')
  }
  Unregister-ScheduledTask -TaskName MicrosoftEdgeUpdate* -Confirm:$false -ea 0; ri "$PROGRAMS\Microsoft\Temp" -recurse -force
} 
$appdata = $([Environment]::GetFolderPath('ApplicationData'))
ri "$appdata\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Tombstones\Microsoft Edge.lnk" -force
ri "$appdata\Microsoft\Internet Explorer\Quick Launch\Microsoft Edge.lnk" -force
	## undo eol unblock trick to prevent latest cumulative update (LCU) failing 
foreach ($sid in $users) { foreach ($PackageName in $eol) {ri "$store\EndOfLife\$sid\$PackageName" -force >''} }
	## .i. "Update policies are configured but will be ignored because this device isn't domain joined" .i.
$uids = @($EDGE_UID); $cdps = @('msedge'); if ($WEBV) {$uids += $WEBV_UID; $cdps += 'msedgewebview'} 
foreach ($sw in $ALLHIVES) {
  sp "$sw\Microsoft\EdgeUpdate" 'DoNotUpdateToEdgeWithChromium' 1 -type Dword -force
  sp "$sw\Microsoft\EdgeUpdate" 'UpdaterExperimentationAndConfigurationServiceControl' 0 -type Dword -force
  sp "$sw\Microsoft\EdgeUpdate" 'InstallDefault' 0 -type Dword -force
  foreach ($uid in $uids) {  
    sp "$sw\Microsoft\EdgeUpdate" "Install${uid}" 0 -type Dword -force
    sp "$sw\Microsoft\EdgeUpdate" "EdgePreview${uid}" 0 -type Dword -force
    sp "$sw\Microsoft\EdgeUpdate" "Update${uid}" 2 -type Dword -force
    foreach ($trigger in 'on-os-upgrade','on-logon','on-logon-autolaunch','on-logon-startup-boost') {
      sp "$sw\Microsoft\EdgeUpdate\Clients\${uid}\Commands\$trigger" 'AutoRunOnLogon' 0 -type Dword -force
      sp "$sw\Microsoft\EdgeUpdate\Clients\${uid}\Commands\$trigger" 'AutoRunOnOSUpgrade' 0 -type Dword -force
      sp "$sw\Microsoft\EdgeUpdate\Clients\${uid}\Commands\$trigger" 'Enabled' 0 -type Dword -force
    }
  }
  sp "$sw\Microsoft\MicrosoftEdge\Main" 'AllowPrelaunch' 0 -type Dword -force
  sp "$sw\Microsoft\MicrosoftEdge\TabPreloader" 'AllowTabPreloading' 0 -type Dword -force
  ## microsoft has no shame, so we are gonna insist opting-out of unsolicited reinstalls with windows updates
  foreach ($cdp in $cdps) { foreach ($arch in 'x64','x86') { foreach ($zdp in '','-zdp') {
    sp "$sw\Microsoft\EdgeUpdateDev\CdpNames" "$cdp-stable-win-$arch$zdp" "$cdp-stable-win-arm64$zdp" -force
  }}}
}
## -------------------------------------------------------------------------------------------------------------------------------
	## 7 add bundled OpenWebSearch script to redirect microsoft-edge: anti-competitive links to the default browser
$MSEP = ($env:ProgramFiles,${env:ProgramFiles(x86)})[[Environment]::Is64BitOperatingSystem] + '\Microsoft\Edge\Application'
$IFEO = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options'
$MIN = ('--headless','--width 1 --height 1')[([environment]::OSVersion.Version.Build) -gt 25179]
$CMD = "$env:systemroot\system32\conhost.exe $MIN" # AveYo: minimize prompt - see Terminal issue #13914
ni "HKLM:\SOFTWARE\Classes\microsoft-edge\shell\open\command" -force >''
sp "HKLM:\SOFTWARE\Classes\microsoft-edge" '(Default)' 'URL:microsoft-edge' -force
sp "HKLM:\SOFTWARE\Classes\microsoft-edge" 'URL Protocol' '' -force
sp "HKLM:\SOFTWARE\Classes\microsoft-edge" 'NoOpenWith' '' -force
sp "HKLM:\SOFTWARE\Classes\microsoft-edge\shell\open\command" '(Default)' "`"$DIR\ie_to_edge_stub.exe`" %1" -force
ni "HKLM:\SOFTWARE\Classes\MSEdgeHTM\shell\open\command" -force >''
sp "HKLM:\SOFTWARE\Classes\MSEdgeHTM" 'NoOpenWith' '' -force
sp "HKLM:\SOFTWARE\Classes\MSEdgeHTM\shell\open\command" '(Default)' "`"$DIR\ie_to_edge_stub.exe`" %1" -force
ni "$IFEO\ie_to_edge_stub.exe\0" -force >''
sp "$IFEO\ie_to_edge_stub.exe" 'UseFilter' 1 -type Dword -force
sp "$IFEO\ie_to_edge_stub.exe\0" 'FilterFullPath' "$DIR\ie_to_edge_stub.exe" -force
sp "$IFEO\ie_to_edge_stub.exe\0" 'Debugger' "$CMD $DIR\OpenWebSearch.cmd" -force
ni "$IFEO\msedge.exe\0" -force >''
sp "$IFEO\msedge.exe" 'UseFilter' 1 -type Dword -force
sp "$IFEO\msedge.exe\0" 'FilterFullPath' "$MSEP\msedge.exe" -force
sp "$IFEO\msedge.exe\0" 'Debugger' "$CMD $DIR\OpenWebSearch.cmd" -force
## new: automatically re-create the needed hardlink if edge is reinstalled
$ta = New-ScheduledTaskAction -Execute '%Temp%\OpenWebSearchRepair.cmd'
$tt = New-ScheduledTaskTrigger -Once -At 00:00; $ts = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries
Register-ScheduledTask -TaskName 'OpenWebSearchRepair' -Action $ta -Trigger $tt -Settings $ts -RunLevel Highest -Force >''
	$OpenWebSearch = @$
@title OpenWebSearch Redux & echo off & set ?= open start menu web search, widgets links or help in your chosen browser - by AveYo
for /f %%E in ('"prompt $E$S& for %%e in (1) do rem"') do echo;%%E[2t 2>nul & rem AveYo: minimize prompt
call :reg_var "HKCU\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice" ProgID ProgID
if /i "%ProgID%" equ "MSEdgeHTM" echo;Default browser is set to Edge! Change it or remove OpenWebSearch script. & pause & exit /b
call :reg_var "HKCR\%ProgID%\shell\open\command" "" Browser
set Choice=& for %%. in (%Browser%) do if not defined Choice set "Choice=%%~."
call :reg_var "HKCR\MSEdgeMHT\shell\open\command" "" FallBack
set "Edge=" & for %%. in (%FallBack%) do if not defined Edge set "Edge=%%~."
set "URI=" & set "URL=" & set "NOOP=" & set "PassTrough=%Edge:msedge=edge%"
set "CLI=%CMDCMDLINE:"=``% "
if defined CLI set "CLI=%CLI:*ie_to_edge_stub.exe`` =%"
if defined CLI set "CLI=%CLI:*ie_to_edge_stub.exe =%"
if defined CLI set "CLI=%CLI:*msedge.exe`` =%"
if defined CLI set "CLI=%CLI:*msedge.exe =%"
set "FIX=%CLI:~-1%"
if defined CLI if "%FIX%"==" " set "CLI=%CLI:~0,-1%"
if defined CLI set "RED=%CLI:microsoft-edge=%"
if defined CLI set "URL=%CLI:http=%"
if defined CLI set "ARG=%CLI:``="%"
if "%CLI%" equ "%RED%" (set NOOP=1) else if "%CLI%" equ "%URL%" (set NOOP=1)
if defined NOOP if not exist "%PassTrough%" echo;@mklink /h "%PassTrough%" "%Edge%" >"%Temp%\OpenWebSearchRepair.cmd"
if defined NOOP if not exist "%PassTrough%" schtasks /run /tn OpenWebSearchRepair 2>nul >nul
if defined NOOP if not exist "%PassTrough%" timeout /t 3 >nul
if defined NOOP if exist "%PassTrough%" start "" "%PassTrough%" %ARG%
if defined NOOP exit /b
set "URL=%CLI:*microsoft-edge=%"
set "URL=http%URL:*http=%"
set "FIX=%URL:~-2%"
if defined URL if "%FIX%"=="``" set "URL=%URL:~0,-2%"
call :dec_url
start "" "%Choice%" "%URL%"
exit
	:reg_var [USAGE] call :reg_var "HKCU\Volatile Environment" value-or-"" variable [extra options]
set {var}=& set {reg}=reg query "%~1" /v %2 /z /se "," /f /e& if %2=="" set {reg}=reg query "%~1" /ve /z /se "," /f /e
for /f "skip=2 tokens=* delims=" %%V in ('%{reg}% %4 %5 %6 %7 %8 %9 2^>nul') do if not defined {var} set "{var}=%%V"
if not defined {var} (set {reg}=& set "%~3="& exit /b) else if %2=="" set "{var}=%{var}:*)    =%"& rem AveYo: v3
if not defined {var} (set {reg}=& set "%~3="& exit /b) else set {reg}=& set "%~3=%{var}:*)    =%"& set {var}=& exit /b
	:dec_url brute url percent decoding by AveYo
set ".=%URL:!=}%"&setlocal enabledelayedexpansion& rem brute url percent decoding
set ".=!.:%%={!" &set ".=!.:{3A=:!" &set ".=!.:{2F=/!" &set ".=!.:{3F=?!" &set ".=!.:{23=#!" &set ".=!.:{5B=[!" &set ".=!.:{5D=]!"
set ".=!.:{40=@!"&set ".=!.:{21=}!" &set ".=!.:{24=$!" &set ".=!.:{26=&!" &set ".=!.:{27='!" &set ".=!.:{28=(!" &set ".=!.:{29=)!"
set ".=!.:{2A=*!"&set ".=!.:{2B=+!" &set ".=!.:{2C=,!" &set ".=!.:{3B=;!" &set ".=!.:{3D==!" &set ".=!.:{25=%%!"&set ".=!.:{20= !"
set ".=!.:{=%%!" &rem set ",=!.:%%=!" & if "!,!" neq "!.!" endlocal& set "URL=%.:}=!%" & call :dec_url
endlocal& set "URL=%.:}=!%" & exit /b
rem done
	$@
[io.file]::WriteAllText("$DIR\OpenWebSearch.cmd", $OpenWebSearch)
## -------------------------------------------------------------------------------------------------------------------------------
	## 8 done
$done = gp 'Registry::HKEY_Users\S-1-5-21*\Volatile*' Edge_Removal -ea 0; if ($done) {rp $done.PSPath Edge_Removal -force -ea 0}
if ((get-process -name 'explorer' -ea 0) -eq $null) {start explorer}
	## bonus enter into powershell console: firefox / edge / webview to install a browser / reinstall edge or webview after removal
${.} = [char]27; $firefox = "${.}[38;2;255;165;0m firefox"; $reinstall = "${.}[96m edge / webview / xsocial${.}[97m "
write-host "`n${.}[40;32m EDGE REMOVED! ${.}[97m -GET-ANOTHER-BROWSER? ENTER:$firefox ${.}[97m -REINSTALL? ENTER:$reinstall"
exit 0
## -------------------------------------------------------------------------------------------------------------------------------
	## 0 ask to run script as admin
'@.replace("$@","'@").replace("@$","@'") -force -ea 0; $code='gp ''Registry::HKEY_Users\S-1-5-21*\Volatile*'' Edge_Removal -ea 0'
start powershell -args "-nop -noe -c & {iex(($code)[0].Edge_Removal)}" -verb runas
$_Press_Enter
#::

 

 
Edited by NotHereToPlayGames
Posted (edited)

Step 4:  Disable "smartscreen", disable the search APP, and disable nonessential services.

Reminder:  don't disable SPOOLER [set first line to auto instead of disabled) if you have a printer installed.

Note:  for those that want to INTENTIONALLY break some GUI "dialogs" (BS things like "toast notifications", "badges", and "live tiles"), set the two Wpn services from auto to disabled.

Caution:  the GUI breaks are not restored simply by returning those to auto!

Source:  none, just standard "public knowledge" across multiple tech forums

Save the below as a <name>.bat file then right-click and Run as administrator.

 

sc.exe config Spooler start= disabled

 

sc.exe config BITS start= disabled

sc.exe config cbdhsvc start= disabled

sc.exe config CDPSvc start= disabled

sc.exe config CDPUserSvc start= disabled

sc.exe config ClipSVC start= disabled

sc.exe config CscService start= disabled

sc.exe config DiagTrack start= disabled

sc.exe config DispBrokerDesktopSvc start= disabled

sc.exe config DPS start= disabled

sc.exe config DsmSvc start= disabled

sc.exe config DusmSvc start= disabled

sc.exe config EventSystem start= disabled

sc.exe config iphlpsvc start= disabled

sc.exe config LanmanServer start= disabled

sc.exe config LanmanWorkstation start= disabled

sc.exe config NcbService start= disabled

sc.exe config PlugPlay start= disabled

sc.exe config RasMan start= disabled

sc.exe config ShellHWDetection start= disabled

sc.exe config StorSvc start= disabled

sc.exe config SysMain start= disabled

sc.exe config TokenBroker start= disabled

sc.exe config TrkWks start= disabled

sc.exe config VaultSvc start= disabled

sc.exe config W32Time start= disabled

sc.exe config WdiServiceHost start= disabled

sc.exe config WinHttpAutoProxySvc start= disabled

sc.exe config WinHttpAutoProxySvc start= disabled

sc.exe config wisvc start= disabled

sc.exe config wlidsvc start= disabled

sc.exe config WPDBusEnum start= disabled

 

sc.exe config WpnService start= auto

sc.exe config WpnUserService start= auto

 

sc.exe config WSearch start= disabled

taskkill /f /im SearchApp.exe

taskkill /f /im SearchApp.exe

taskkill /f /im SearchApp.exe

move %windir%\SystemApps\Microsoft.Windows.Search_cw5n1h2txyewy %windir%\SystemApps\Microsoft.Windows.Search_cw5n1h2txyewy.old

 

takeown /f "%systemroot%\System32\smartscreen.exe" /a

icacls "%systemroot%\System32\smartscreen.exe" /reset

taskkill /im smartscreen.exe /f

icacls "%systemroot%\System32\smartscreen.exe" /inheritance:r /remove *S-1-5-32-544 *S-1-5-11 *S-1-5-32-545 *S-1-5-18

Edited by NotHereToPlayGames

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...