Skip to content

Fix Remove-AI-CBS-Packages operator precedence corrupting component store - #234

Open
snowzhangy wants to merge 1 commit into
zoicware:mainfrom
snowzhangy:fix/cbs-removal-corrupts-touch-keyboard
Open

Fix Remove-AI-CBS-Packages operator precedence corrupting component store#234
snowzhangy wants to merge 1 commit into
zoicware:mainfrom
snowzhangy:fix/cbs-removal-corrupts-touch-keyboard

Conversation

@snowzhangy

Copy link
Copy Markdown

Summary

  • Remove-AI-CBS-Packages's visibility check (Visibility -eq 2) was only scoped to the *AIX* pattern due to missing parentheses (-and binds tighter than -or), so *Recall*/*Copilot*/*CoreAI* matched any CBS package by name regardless of whether it was actually hidden.
  • The function also strips a matched package's Owners/Updates registry subkeys before forcing removal via Remove-WindowsPackage/DISM, which bypasses the normal dependency-tracking safety net Windows servicing relies on.
  • On a Windows 11 25H2 test machine, this combination corrupted ~605 files in the component store (confirmed via DISM/SFC logs: Total Repaired Corruption: 605 right after this function ran) and broke TextInputHost.exe — the touch keyboard/handwriting panel host, shipped in the MicrosoftWindows.Client.CBS package on this build — which then crashed on every launch with 0xc0000409 in Windows.UI.Xaml.dll. Fix required DISM /RestoreHealth with matching install media + a reboot.
  • Also removes the InpApp pattern from both $aipackages arrays — MicrosoftWindows.Client.InputApp is the touch keyboard host package on older Windows builds and shouldn't be targeted by AI removal either.

Changes

  • Add the missing parentheses so all four name patterns require Visibility -eq 2 as originally intended, narrowing the removal back to genuinely hidden packages.
  • Add an explicit exclude list (Client.CBS, TextInput, InputApp, Client.CBSPreview) so packages backing the text-input/touch-keyboard stack can never be matched by this removal path, even if hidden.
  • Drop InpApp from both $aipackages arrays.

Test plan

  • Run the script on a machine with a hidden CBS package matching one of the AI patterns and confirm it's still removed when genuinely hidden and not on the exclude list.
  • Confirm touch keyboard / TextInputHost.exe still launches normally after running the script.

…k packages

The visibility check (Visibility -eq 2) was only scoped to the AIX pattern due
to missing parentheses, so PSChildName -like '*Recall*'/'*Copilot*'/'*CoreAI*'
matched any CBS package regardless of whether it was actually hidden. Combined
with this function manually stripping a package's Owners/Updates registry
subkeys before forcing removal (bypassing DISM's normal dependency tracking),
a hidden CBS package sharing WinSxS payloads with other components could take
those shared files down with it.

On a Windows 11 25H2 test machine this corrupted ~605 component-store files
and crashed TextInputHost.exe (touch keyboard/handwriting panel host, now
shipped in the MicrosoftWindows.Client.CBS package) on every launch with
0xc0000409 in Windows.UI.Xaml.dll. Confirmed root cause via DISM/SFC logs
showing "Total Repaired Corruption: 605" right after this function ran, and
fixed only after a DISM RestoreHealth + reboot repaired the component store.

This adds the missing parens so all four name patterns require Visibility -eq 2
as originally intended, adds an explicit exclude list for CBS/text-input
packages so they can never be matched by this removal path even if hidden,
and drops the now-unnecessary 'InpApp' match from the two $aipackages arrays
(MicrosoftWindows.Client.InputApp is the touch keyboard host on older builds
and shouldn't be targeted either).
@zoicware

Copy link
Copy Markdown
Owner

a few things:

  1. yes the parenthesis makes this if statements logic more correct however it doesn't actually effect anything negatively since the path would still contain one of the wild cards

Without paren

Microsoft-Copilot-Package~31bf3856ad364e35~amd64~en-US~10.0.26100.1301
Microsoft-Copilot-Package~31bf3856ad364e35~amd64~~10.0.26100.1301
UserExperience-AIX-Package~31bf3856ad364e35~amd64~~10.0.26100.1591
UserExperience-AIX-Package~31bf3856ad364e35~amd64~~10.0.26100.8246
UserExperience-AIX-Package~31bf3856ad364e35~amd64~~10.0.26100.8457
UserExperience-AIX-Package~31bf3856ad364e35~amd64~~10.0.26100.8521
UserExperience-Recall-Package~31bf3856ad364e35~amd64~~10.0.26100.1591
UserExperience-Recall-Package~31bf3856ad364e35~amd64~~10.0.26100.8246
UserExperience-Recall-Package~31bf3856ad364e35~amd64~~10.0.26100.8457
UserExperience-Recall-Package~31bf3856ad364e35~amd64~~10.0.26100.8521

With paren

Microsoft-Copilot-Package~31bf3856ad364e35~amd64~en-US~10.0.26100.1301
Microsoft-Copilot-Package~31bf3856ad364e35~amd64~~10.0.26100.1301
UserExperience-AIX-Package~31bf3856ad364e35~amd64~~10.0.26100.1591
UserExperience-AIX-Package~31bf3856ad364e35~amd64~~10.0.26100.8246
UserExperience-AIX-Package~31bf3856ad364e35~amd64~~10.0.26100.8457
UserExperience-AIX-Package~31bf3856ad364e35~amd64~~10.0.26100.8521
UserExperience-Recall-Package~31bf3856ad364e35~amd64~~10.0.26100.1591
UserExperience-Recall-Package~31bf3856ad364e35~amd64~~10.0.26100.8246
UserExperience-Recall-Package~31bf3856ad364e35~amd64~~10.0.26100.8457
UserExperience-Recall-Package~31bf3856ad364e35~amd64~~10.0.26100.8521
  1. i dont understand the change to protect client cbs packages as these are not found if you have output showing that please provide it (as i did above)

  2. obviously there is some ai issues going on here since its not able to actually run it on a windows machine it doesn't really understand why things are the way they are

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants