Use DISM component cleanup against the running operating system. This removes superseded component versions from the WinSxS store while keeping the system in a supported state. Run the following command from an elevated Command Prompt or PowerShell session:
DISM /Online /Cleanup-Image /StartComponentCleanup
This performs a standard component store cleanup and removes older replaced component versions that are no longer needed after Windows updates.
If you want to permanently remove all superseded components and prevent uninstalling older updates or service packs, use:
DISM /Online /Cleanup-Image /StartComponentCleanup /ResetBase
The /ResetBase option significantly reduces WinSxS size because every currently installed update becomes permanent. After running it, previously installed updates can no longer be uninstalled, so it is best used only after validating system stability and patch compliance.
You can also automate the cleanup with PowerShell:
Start-Process dism.exe -ArgumentList '/Online','/Cleanup-Image','/StartComponentCleanup','/ResetBase' -Wait -Verb RunAs
Before cleanup, you can analyze the component store size with:
DISM /Online /Cleanup-Image /AnalyzeComponentStore
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin