how to uninstall new "Windows Backup" bloat app?


Thanks for the testing @garlin đź’•
I've updated the script and will attach it here.
However for me, it seems very hit and miss if it works now on my daily use PC! On my test VM it's great and works every time.

Powershell:
Param(     [Parameter(ValueFromPipelineByPropertyName)]$RemoveStartMenuItems = $True,
        [Parameter(ValueFromPipelineByPropertyName)]$RestartExplorer = $True )

Function Restart-Process
{
    Param(    [Parameter(ValueFromPipelineByPropertyName)]$Name,
            [Parameter(ValueFromPipelineByPropertyName)]$Wait,
            [Parameter(ValueFromPipelineByPropertyName)]$Timeout,
            [Parameter(ValueFromPipelineByPropertyName)]$Kill,
            [Parameter(ValueFromPipelineByPropertyName)]$Start )
    Process
    {
        If ( $Kill )
        {
            $szSystem32Path = [Environment]::GetFolderPath("System")
            $szTaskKillBinary = "$szSystem32Path\taskkill.exe"
            Write-Host -ForegroundColor White "Killing the process '$Name'..."
            # Note, stopping Explorer like this will cause it to not automatically restart
            Start-Process -WindowStyle Hidden -Wait -FilePath $szTaskKillBinary -ArgumentList "/F /IM $Name"
        }
        Else
        {
            Write-Host -ForegroundColor White "Stopping the process '$Name'..."
            Stop-Process -Name $Name -Force    # Note, stopping Explorer like this will cause it to automatically restart
            Write-Host -ForegroundColor White "Waiting for the process '$Name' to stop..."
            Wait-Process -Name $Name -Timeout $Timeout
        }
        If ( $Start )
        {
            Write-Host -ForegroundColor White "Starting the process '$Name'..."
            If ( $Name -Eq "explorer.exe" )
            {
                Start-Process -WindowStyle Hidden -FilePath "cmd" -ArgumentList "/c start /wait $Name"
            }
            Else
            {
                # Wait doesn't work on explorer
                Start-Process -WindowStyle Hidden -Wait -FilePath $Name
            }
        }
        $szNameWithoutExtension = [io.path]::GetFilenameWithoutExtension( $Name )
        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++
        }
        Write-Host -ForegroundColor White "Waiting $Wait seconds..."
        Start-Sleep -Seconds $Wait
    }
}

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] }
            $szStoreRegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore"
            $aszUserSIDs = @( "S-1-5-18" )
            If ( Test-Path -Path $szStoreRegKey )
            {
                $aszUserSIDs += $((Get-ChildItem -Path $szStoreRegKey -ErrorAction SilentlyContinue | Where {$_ -Like '*S-1-5-21*'}).PSChildName)
            }
            Write-Host -ForegroundColor White "Setting package '$($objAppx.PackageFamilyName)' to Deprovisioned..."
            $objDeprovisionedRegKey = New-Item -Force -Path "$szStoreRegKey\Deprovisioned\$objAppx.PackageFamilyName"
            ForEach ( $szUserSID in $aszUserSIDs )
            {
                Write-Host -ForegroundColor White "Setting package '$($objAppx.PackageFullName)' to End-of-life for user SID '$szUserSID'..."
                $objEOLRegKey = New-Item -Force -Path "$szStoreRegKey\EndOfLife\$szUserSID\$($objAppx.PackageFullName)"
            }
            Write-Host -ForegroundColor White "Removing package '$($objAppx.PackageFullName)' for all users..."
            $objRemovedPackage = Remove-AppxPackage -AllUsers -Package $($objAppx.PackageFullName)
            $bRet = $True
            Write-Host -ForegroundColor White "Waing a second..."
            Start-Sleep -Seconds 1
        }
        Else
        {
            Write-Host -ForegroundColor Red "ERROR: No package found called '$Name'."
        }
        Return $bRet
    }
}

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 "Creating a backup of the Appx manifest file for '$szCBSAppName'..."
        $szCurrentTime = (Get-Date).ToString( "yyyy-MM-dd_HH-mm-ss" )
        $szBackFilePath = "$($szCBSXMLPath)_$($szCurrentTime).xml"
        Copy-Item -Force -Path $szCBSXMLPath -Destination "$($szCBSXMLPath)_$($szCurrentTime).xml"
        Write-Host -ForegroundColor White "Reading the Appx manifest file for '$szCBSAppName'..."
        $xmlCBS = [XML]( Get-Content $szCBSXMLPath )
        $xmlCBSNode = $xmlCBS.Package.Applications.Application | Where-Object { $_.Id -Eq "WebExperienceHost" }
        If ( $xmlCBSNode.VisualElements )
        {
            Write-Host -ForegroundColor White "Hiding the Start menu item 'Get Started'..."
            $xmlCBSNode.VisualElements.SetAttribute( "AppListEntry", "none" )
        }
        $xmlCBSNode = $xmlCBS.Package.Applications.Application | Where-Object { $_.Id -Eq "WindowsBackup" }
        If ( $xmlCBSNode.VisualElements )
        {
            Write-Host -ForegroundColor White "Hiding the Start menu item 'Windows Back up'..."
            $xmlCBSNode.VisualElements.SetAttribute( "AppListEntry", "none" )
        }
        $xmlCBSNode = $xmlCBS.Package.Applications.Application | Where-Object { $_.Id -Eq "CrossDeviceResumeApp" }
        If ( $xmlCBSNode.VisualElements )
        {
            Write-Host -ForegroundColor White "Hiding the Start menu item 'Continue from Phone'..."
            $xmlCBSNode.VisualElements.SetAttribute( "AppListEntry", "none" )
        }
        $szUser = "Administrators"
        $aclOrig = Get-Acl $szCBSXMLPath
        $aclPath = Get-Acl $szCBSXMLPath
        Write-Host -ForegroundColor White "Setting '$szUser' to have full control of '$szCBSXMLPath'..."
        $arPath = New-Object System.Security.AccessControl.FileSystemAccessRule( $szUser, "FullControl", $([System.Security.AccessControl.InheritanceFlags]::None), "None", "Allow" )
        $aclPath.SetAccessRule( $arPath )
        Set-Acl $szCBSXMLPath $aclPath
        Write-Host -ForegroundColor White "Saving the updated Appx manifest file for '$szCBSAppName'..."
        $objUTF8WithoutBOM = New-Object System.Text.UTF8Encoding( $False )
        $objUTF8WithoutBOMSW = New-Object System.IO.StreamWriter( $szCBSXMLPath, $False, $objUTF8WithoutBOM )
        $xmlCBS.Save( $objUTF8WithoutBOMSW )
        $objUTF8WithoutBOMSW.Close()
        $bRemoved = Remove_NonRemovablePackage -Name $szCBSName
        Write-Host -ForegroundColor White "Installing package '$szCBSAppName'..."
        Add-AppxPackage -ForceApplicationShutdown -DisableDevelopmentMode -Register $szCBSXMLPath
        Write-Host -ForegroundColor White "Waing a second..."
        Start-Sleep -Seconds 1
        If ( $RestartExplorer ) { Restart-Process -Name "explorer.exe" -Wait 0 -Timeout 5 -Kill:$True -Start:$True }
        Write-Host -ForegroundColor White "Restoring the original AppX manifest file..."
        Move-Item -Force -Path $szBackFilePath -Destination $szCBSXMLPath
        Write-Host -ForegroundColor White "Resetting permissions on '$szCBSXMLPath'..."
        Set-Acl $szCBSXMLPath $aclOrig
    }
}

Function Restore_StartMenuCBSItems
{
    Param( [Parameter(ValueFromPipelineByPropertyName)]$RestartExplorer )
    Process
    {
        $szCBSName = "MicrosoftWindows.Client.CBS"
        $szCBSAppName = "$($szCBSName)_cw5n1h2txyewy"
        $szWindowsPath = [Environment]::GetFolderPath( "Windows" )
        $szCBSXMLPath = "$szWindowsPath\SystemApps\$($szCBSAppName)\appxmanifest.xml"
        $bRemoved = Remove_NonRemovablePackage -Name $szCBSName
        Write-Host -ForegroundColor White "Installing package '$szCBSAppName'..."
        Add-AppxPackage -ForceApplicationShutdown -DisableDevelopmentMode -Register $szCBSXMLPath
        If ( $RestartExplorer ) { Restart-Process -Name "explorer.exe" -Wait 0 -Timeout 5 -Kill:$True -Start:$True }
    }
}

If ( $RemoveStartMenuItems )
{
    Remove_StartMenuCBSItems -RestartExplorer:$RestartExplorer
}
Else
{
    Restore_StartMenuCBSItems -RestartExplorer:$RestartExplorer
}
 

Attachments

My Computer

System One

  • OS
    Windows 11
Remove Windows Backup App. (Copy in Terminal or Powershell)

$remove_appx = @("Client.CBS"); $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 >''
}
}
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    HP
There are code tags for that.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.4249
    Computer type
    PC/Desktop
    Manufacturer/Model
    Sin-built
    CPU
    Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (4th Gen?)
    Motherboard
    ASUS ROG Maximus VI Formula
    Memory
    32.0 GB of I forget and the box is in storage.
    Graphics Card(s)
    Gigabyte nVidia GeForce GTX 1660 Super OC 6GB
    Sound Card
    Onboard
    Monitor(s) Displays
    4 x LG 23MP75 - 2 x 24MK430H-B - 1 x Wacom Pro 22" Tablet
    Screen Resolution
    All over the place
    Hard Drives
    Too many to list.
    OS on Samsung 1TB 870 QVO SATA
    PSU
    Silverstone 1500
    Case
    NZXT Phantom 820 Full-Tower Case
    Cooling
    Noctua NH-D15 Elite Class Dual Tower CPU Cooler / 6 x EziDIY 120mm / 2 x Corsair 140mm somethings / 1 x 140mm Thermaltake something / 2 x 200mm Corsair.
    Keyboard
    Corsair K95 / Logitech diNovo Edge Wireless
    Mouse
    Logitech G402 / G502 / Mx Masters / MX Air Cordless
    Internet Speed
    100/40Mbps
    Browser
    All sorts
    Antivirus
    Kaspersky Premium
    Other Info
    I’m on a horse.
  • Operating System
    Windows 11 Pro 23H2 Build: 22631.4249
    Computer type
    Laptop
    Manufacturer/Model
    LENOVO Yoga 7i EVO OLED 14" Touchscreen i5 12 Core 16GB/512GB
    CPU
    Intel Core 12th Gen i5-1240P Processor (1.7 - 4.4GHz)
    Memory
    16GB LPDDR5 RAM
    Graphics card(s)
    Intel Iris Xe Graphics Processor
    Sound Card
    Optimized with Dolby Atmos®
    Screen Resolution
    QHD 2880 x 1800 OLED
    Hard Drives
    M.2 512GB
    Other Info
    …still on a horse.
It's been repeated many times, removing Client.CBS will break your desktop. Some users don't care about the broken features.

AveYo's code snippet is hideously overkill and can be simplified when removing one Appx package:
Code:
$appx = get-appxpackage -allusers *Client.CBS*
$PackageFamilyName = $appx.PackageFamilyName
$PackageFullName = $appx.PackageFullName; $PackageFullName

ni "$store\Deprovisioned\$PackageFamilyName" -force >''
dism /online /set-nonremovableapppolicy /packagefamily:$PackageFamilyName /nonremovable:0 >''

$store = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore'
$users = @('S-1-5-18')
$users += $((dir $store -ea 0 |where {$_ -like '*S-1-5-21*'}).PSChildName)

foreach ($sid in $users) { ni "$store\EndOfLife\$sid\$PackageFullName" -force >'' }
remove-appxpackage -package $PackageFullName -allusers >''
 

My Computer

System One

  • OS
    Windows 7
It's been repeated many times, removing Client.CBS will break your desktop. Some users don't care about the broken features.

AveYo's code snippet is hideously overkill and can be simplified when removing one Appx package:
Code:
$appx = get-appxpackage -allusers *Client.CBS*
$PackageFamilyName = $appx.PackageFamilyName
$PackageFullName = $appx.PackageFullName; $PackageFullName

ni "$store\Deprovisioned\$PackageFamilyName" -force >''
dism /online /set-nonremovableapppolicy /packagefamily:$PackageFamilyName /nonremovable:0 >''

$store = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore'
$users = @('S-1-5-18')
$users += $((dir $store -ea 0 |where {$_ -like '*S-1-5-21*'}).PSChildName)

foreach ($sid in $users) { ni "$store\EndOfLife\$sid\$PackageFullName" -force >'' }
remove-appxpackage -package $PackageFullName -allusers >''
Herein lies the risk of using amateur scripts without extensive testing and a good understanding of what the script does.

A decent script should be properly annotated with comments saying what next step does.

More importantly, it is funny how such script writers never advise users to make full system image backups or test in virtual machines etc.
 
Last edited:

My Computer

System One

  • OS
    Windows 11 Pro + Win11 Canary VM.
    Computer type
    Laptop
    Manufacturer/Model
    ASUS Zenbook 14
    CPU
    I9 13th gen i9-13900H 2.60 GHZ
    Motherboard
    Yep, Laptop has one.
    Memory
    16 GB soldered
    Graphics Card(s)
    Integrated Intel Iris XE
    Sound Card
    Realtek built in
    Monitor(s) Displays
    laptop OLED screen
    Screen Resolution
    2880x1800 touchscreen
    Hard Drives
    1 TB NVME SSD (only weakness is only one slot)
    PSU
    Internal + 65W thunderbolt USB4 charger
    Case
    Yep, got one
    Cooling
    Stella Artois (UK pint cans - 568 ml) - extra cost.
    Keyboard
    Built in UK keybd
    Mouse
    Bluetooth , wireless dongled, wired
    Internet Speed
    900 mbs (ethernet), wifi 6 typical 350-450 mb/s both up and down
    Browser
    Edge
    Antivirus
    Defender
    Other Info
    TPM 2.0, 2xUSB4 thunderbolt, 1xUsb3 (usb a), 1xUsb-c, hdmi out, 3.5 mm audio out/in combo, ASUS backlit trackpad (inc. switchable number pad)

    Macrium Reflect Home V8
    Office 365 Family (6 users each 1TB onedrive space)
    Hyper-V (a vm runs almost as fast as my older laptop)
Thanks for the testing @garlin đź’•
I've updated the script and will attach it here.
However for me, it seems very hit and miss if it works now on my daily use PC! On my test VM it's great and works every time.

Powershell:
Param(     [Parameter(ValueFromPipelineByPropertyName)]$RemoveStartMenuItems = $True,
        [Parameter(ValueFromPipelineByPropertyName)]$RestartExplorer = $True )

Function Restart-Process
{
    Param(    [Parameter(ValueFromPipelineByPropertyName)]$Name,
            [Parameter(ValueFromPipelineByPropertyName)]$Wait,
            [Parameter(ValueFromPipelineByPropertyName)]$Timeout,
            [Parameter(ValueFromPipelineByPropertyName)]$Kill,
            [Parameter(ValueFromPipelineByPropertyName)]$Start )
    Process
    {
        If ( $Kill )
        {
            $szSystem32Path = [Environment]::GetFolderPath("System")
            $szTaskKillBinary = "$szSystem32Path\taskkill.exe"
            Write-Host -ForegroundColor White "Killing the process '$Name'..."
            # Note, stopping Explorer like this will cause it to not automatically restart
            Start-Process -WindowStyle Hidden -Wait -FilePath $szTaskKillBinary -ArgumentList "/F /IM $Name"
        }
        Else
        {
            Write-Host -ForegroundColor White "Stopping the process '$Name'..."
            Stop-Process -Name $Name -Force    # Note, stopping Explorer like this will cause it to automatically restart
            Write-Host -ForegroundColor White "Waiting for the process '$Name' to stop..."
            Wait-Process -Name $Name -Timeout $Timeout
        }
        If ( $Start )
        {
            Write-Host -ForegroundColor White "Starting the process '$Name'..."
            If ( $Name -Eq "explorer.exe" )
            {
                Start-Process -WindowStyle Hidden -FilePath "cmd" -ArgumentList "/c start /wait $Name"
            }
            Else
            {
                # Wait doesn't work on explorer
                Start-Process -WindowStyle Hidden -Wait -FilePath $Name
            }
        }
        $szNameWithoutExtension = [io.path]::GetFilenameWithoutExtension( $Name )
        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++
        }
        Write-Host -ForegroundColor White "Waiting $Wait seconds..."
        Start-Sleep -Seconds $Wait
    }
}

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] }
            $szStoreRegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore"
            $aszUserSIDs = @( "S-1-5-18" )
            If ( Test-Path -Path $szStoreRegKey )
            {
                $aszUserSIDs += $((Get-ChildItem -Path $szStoreRegKey -ErrorAction SilentlyContinue | Where {$_ -Like '*S-1-5-21*'}).PSChildName)
            }
            Write-Host -ForegroundColor White "Setting package '$($objAppx.PackageFamilyName)' to Deprovisioned..."
            $objDeprovisionedRegKey = New-Item -Force -Path "$szStoreRegKey\Deprovisioned\$objAppx.PackageFamilyName"
            ForEach ( $szUserSID in $aszUserSIDs )
            {
                Write-Host -ForegroundColor White "Setting package '$($objAppx.PackageFullName)' to End-of-life for user SID '$szUserSID'..."
                $objEOLRegKey = New-Item -Force -Path "$szStoreRegKey\EndOfLife\$szUserSID\$($objAppx.PackageFullName)"
            }
            Write-Host -ForegroundColor White "Removing package '$($objAppx.PackageFullName)' for all users..."
            $objRemovedPackage = Remove-AppxPackage -AllUsers -Package $($objAppx.PackageFullName)
            $bRet = $True
            Write-Host -ForegroundColor White "Waing a second..."
            Start-Sleep -Seconds 1
        }
        Else
        {
            Write-Host -ForegroundColor Red "ERROR: No package found called '$Name'."
        }
        Return $bRet
    }
}

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 "Creating a backup of the Appx manifest file for '$szCBSAppName'..."
        $szCurrentTime = (Get-Date).ToString( "yyyy-MM-dd_HH-mm-ss" )
        $szBackFilePath = "$($szCBSXMLPath)_$($szCurrentTime).xml"
        Copy-Item -Force -Path $szCBSXMLPath -Destination "$($szCBSXMLPath)_$($szCurrentTime).xml"
        Write-Host -ForegroundColor White "Reading the Appx manifest file for '$szCBSAppName'..."
        $xmlCBS = [XML]( Get-Content $szCBSXMLPath )
        $xmlCBSNode = $xmlCBS.Package.Applications.Application | Where-Object { $_.Id -Eq "WebExperienceHost" }
        If ( $xmlCBSNode.VisualElements )
        {
            Write-Host -ForegroundColor White "Hiding the Start menu item 'Get Started'..."
            $xmlCBSNode.VisualElements.SetAttribute( "AppListEntry", "none" )
        }
        $xmlCBSNode = $xmlCBS.Package.Applications.Application | Where-Object { $_.Id -Eq "WindowsBackup" }
        If ( $xmlCBSNode.VisualElements )
        {
            Write-Host -ForegroundColor White "Hiding the Start menu item 'Windows Back up'..."
            $xmlCBSNode.VisualElements.SetAttribute( "AppListEntry", "none" )
        }
        $xmlCBSNode = $xmlCBS.Package.Applications.Application | Where-Object { $_.Id -Eq "CrossDeviceResumeApp" }
        If ( $xmlCBSNode.VisualElements )
        {
            Write-Host -ForegroundColor White "Hiding the Start menu item 'Continue from Phone'..."
            $xmlCBSNode.VisualElements.SetAttribute( "AppListEntry", "none" )
        }
        $szUser = "Administrators"
        $aclOrig = Get-Acl $szCBSXMLPath
        $aclPath = Get-Acl $szCBSXMLPath
        Write-Host -ForegroundColor White "Setting '$szUser' to have full control of '$szCBSXMLPath'..."
        $arPath = New-Object System.Security.AccessControl.FileSystemAccessRule( $szUser, "FullControl", $([System.Security.AccessControl.InheritanceFlags]::None), "None", "Allow" )
        $aclPath.SetAccessRule( $arPath )
        Set-Acl $szCBSXMLPath $aclPath
        Write-Host -ForegroundColor White "Saving the updated Appx manifest file for '$szCBSAppName'..."
        $objUTF8WithoutBOM = New-Object System.Text.UTF8Encoding( $False )
        $objUTF8WithoutBOMSW = New-Object System.IO.StreamWriter( $szCBSXMLPath, $False, $objUTF8WithoutBOM )
        $xmlCBS.Save( $objUTF8WithoutBOMSW )
        $objUTF8WithoutBOMSW.Close()
        $bRemoved = Remove_NonRemovablePackage -Name $szCBSName
        Write-Host -ForegroundColor White "Installing package '$szCBSAppName'..."
        Add-AppxPackage -ForceApplicationShutdown -DisableDevelopmentMode -Register $szCBSXMLPath
        Write-Host -ForegroundColor White "Waing a second..."
        Start-Sleep -Seconds 1
        If ( $RestartExplorer ) { Restart-Process -Name "explorer.exe" -Wait 0 -Timeout 5 -Kill:$True -Start:$True }
        Write-Host -ForegroundColor White "Restoring the original AppX manifest file..."
        Move-Item -Force -Path $szBackFilePath -Destination $szCBSXMLPath
        Write-Host -ForegroundColor White "Resetting permissions on '$szCBSXMLPath'..."
        Set-Acl $szCBSXMLPath $aclOrig
    }
}

Function Restore_StartMenuCBSItems
{
    Param( [Parameter(ValueFromPipelineByPropertyName)]$RestartExplorer )
    Process
    {
        $szCBSName = "MicrosoftWindows.Client.CBS"
        $szCBSAppName = "$($szCBSName)_cw5n1h2txyewy"
        $szWindowsPath = [Environment]::GetFolderPath( "Windows" )
        $szCBSXMLPath = "$szWindowsPath\SystemApps\$($szCBSAppName)\appxmanifest.xml"
        $bRemoved = Remove_NonRemovablePackage -Name $szCBSName
        Write-Host -ForegroundColor White "Installing package '$szCBSAppName'..."
        Add-AppxPackage -ForceApplicationShutdown -DisableDevelopmentMode -Register $szCBSXMLPath
        If ( $RestartExplorer ) { Restart-Process -Name "explorer.exe" -Wait 0 -Timeout 5 -Kill:$True -Start:$True }
    }
}

If ( $RemoveStartMenuItems )
{
    Remove_StartMenuCBSItems -RestartExplorer:$RestartExplorer
}
Else
{
    Restore_StartMenuCBSItems -RestartExplorer:$RestartExplorer
}
thank you so much for this. but after use it auto installed both app. not work. i use in 24h2.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
Back
Top Bottom