Clean Up the WinSxS Folder

https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/clean-up-the-winsxs-folder


This topic is about the different ways to reduce the size of the WinSxS folder on a running version of Windows 10.

One commonly asked question is, "Can I delete the WinSxS folder to regain some disk space?" The short answer is no. You can, however, reduce the size of the WinSxS folder using tools built into Windows. For more information about the WinSxS folder, see Manage the Component Store.

Windows 10 and Windows Server 2016 automatically reduce the size of the WinSxS folder by using methods similar to the ones described in this topic, in addition to internal processes, such as uninstalling and deleting packages with components that have been replaced by other components with newer versions. Previous versions of some components are kept on the system for a period of time, allowing you to rollback if necessary. After a period of time, these older components are automatically removed from the installation.

You can also reduce the size of a Windows image using some of the same techniques, as discussed in Reduce the Size of the Component Store in an Offline Windows Image.

To learn about finding the size of your WinSxS folder, see Determine the actual size of the WinSxS folder.

Warning

Deleting files from the WinSxS folder or deleting the entire WinSxS folder may severely damage your system so that your PC might not boot and make it impossible to update.

In Windows 10 and Windows Server 2016, you have a number of ways to start the cleanup of the component store, which use a combination of package deletion and component compression to clean up the WinSxS folder:

Task Scheduler

The StartComponentCleanup task was created in Windows 8 to regularly clean up components automatically when the system is not in use. This task is set to run automatically when triggered by the operating system. When run automatically, the task will wait at least 30 days after an updated component has been installed before uninstalling the previous versions of the component.

If you choose to run this task, the task will have a 1 hour timeout and may not completely clean up all files.

Run the StartComponentCleanup task in Task Scheduler to clean up and compress components

  1. If Task Scheduler is not open, start the Task Scheduler. For more information, see Start Task Scheduler.

  2. Expand the console tree and navigate to Task Scheduler Library\Microsoft\Windows\Servicing\StartComponentCleanup.

  3. Under Selected Item, click Run

  1. schtasks.exe /Run /TN "\Microsoft\Windows\Servicing\StartComponentCleanup"
    

    Note

    The StartComponentCleanup task can also be started from the command line.

Dism.exe

The /Cleanup-Image parameter of Dism.exe provides advanced users more options to further reduce the size of the WinSxS folder. For more information, see DISM Operating System Package Servicing Command-Line Options.

Use the /StartComponentCleanup parameter

  • Using the /StartComponentCleanup parameter of Dism.exe on a running version of Windows 10 gives you similar results to running the StartComponentCleanup task in Task Scheduler, except previous versions of updated components will be immediately deleted (without a 30 day grace period) and you will not have a 1-hour timeout limitation.

    From an elevated command prompt, type the following:

  • Dism.exe /online /Cleanup-Image /StartComponentCleanup
    

Use the /ResetBase switch with the /StartComponentCleanup parameter

  • Using the /ResetBase switch with the /StartComponentCleanup parameter of DISM.exe on a running version of Windows 10 removes all superseded versions of every component in the component store.

    From an elevated command prompt, type the following:

  • Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
    

    Warning

    All existing service packs and updates cannot be uninstalled after this command is completed. This will not block the uninstallation of future service packs or updates.

Use the /SPSuperseded parameter

  • To reduce the amount of space used by a Service Pack, use the /SPSuperseded parameter of Dism.exe on a running version of Windows 10 to remove any backup components needed for uninstallation of the service pack. A service pack is a collection of cumulative updates for a particular release of Windows.

    From an elevated command prompt, type the following:

  • Dism.exe /online /Cleanup-Image /SPSuperseded
    

    Warning
    The service pack cannot be uninstalled after this command is completed.

Disk Cleanup

You can use Disk Cleanup to reduce the number of unnecessary files on your drives, which can help your PC run faster. It can delete temporary files and system files, empty the Recycle Bin, and remove a variety of other items that you might no longer need. The option to cleanup updates helps reduce the size of the component store.

Run Disk Cleanup to delete system files

Related topics

Manage the Component Store

Determine the Actual Size of the WinSxS Folder

Reduce the Size of the Component Store in an Offline Windows Image

Uninstall-WindowsFeature

How to Reduce the Size of the Winsxs directory and Free Up Disk Space on Windows Server 2012 Using Features on Demand

How to address disk space issues that are caused by a large Windows component store (WinSxS) directory
winsxs文件夹瘦身方法: vista,windows2008,windows7的许多系统组件(主要是动态库)被安装在windows\winsxs目录下, 但是,对于同一组件,由于升级以及其它原因,windows并没有删除低版本的同一组件。 所以这里的瘦身方法就是删除多余的低版本组件。 考虑到系统的稳定及兼容性,本工具仅只分离多余的低版本组件,并未作任何删除。 (不同大版本号的同一组件视为不同组件,也就是说仅只分离小版本号不同的组件) (同版本的不同语言组件同样视为不同组件,不作分离) 例如:组件 x86_microsoft-windows-i..ersandsecurityzones_31bf3856ad364e35在我的winsxs下有如下版本   ver: 8.0.6001.18702 视为不同组件,当然若有不同语言版本也视为不同组件,不作分离 ver: 6.0.6001.18000 ver: 6.0.6001.18023 ver: 6.0.6001.18063 ver: 6.0.6001.18099 ver: 6.0.6001.18157 ver: 6.0.6001.18203 ver: 6.0.6001.18226 ver: 6.0.6001.22120 ver: 6.0.6001.22167 ver: 6.0.6001.22212 ver: 6.0.6001.22288 ver: 6.0.6001.22355 ver: 6.0.6001.22389 使用方法: 1.取得windows\winsxs的管理员权限, 以管理员身份运行permission_Cwinsxs.bat(当前系统安装在C盘),大约要运行5分钟 或permission_Dwinsxs.bat(当前系统安装在D盘),安装其它盘的请自行修改。 2.copy "winsxsCleaner.exe" 到winsxs目录下,运行,大约要等3分钟或者更多 完成后,多余的动态库已经被转移到winsxs下的__redundance目录下 3.请自行处理__redundance目录,建议备份后再删除。 此法同样适用于windows7。 由此瘦身方法造成的任何缺失,损失和后果本人一概不于负责。 附上原代码,请放心使用
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值