Windows用户对存储的追求永无止境。一月份(January)清理电脑,春天之前你的存储空间又会被用光。当您深入了解占用该磁盘空间的内容时,您可能会遇到Windows计算机上的WinSxS文件夹。
什么是 WinSxS 文件夹?
WinSxS(“ Windows Side by Side”的缩写)是一个文件夹(位置:C:Windows WinSxS),Windows在其中存储安装(Windows)Windows 所需的文件以及(and)这些文件的备份或版本。
每当您需要恢复系统文件(recover system files)或添加或删除Windows功能时,Windows都会在此处搜索执行操作所需的文件。这就是为什么它也被称为组件存储。
WinSxS还存储安装质量更新和以前版本的Windows组件所需的文件。这些文件允许您恢复到上一个状态,以防更新变得麻烦。
随着时间的推移, WinSxS(WinSxS)的大小会继续增加,因为它将继续存储更多的组件版本。
WinSxS 的正确大小是多少?
WinSxS文件夹的大小通常由文件资源管理器(File Explorer)计算不准确。
WinSxS文件夹中的文件可能出现在操作系统的多个位置。但是,一个文件通常只有一个副本,而其余文件是硬链接(hard links)。
文件资源管理器(File Explorer)在计算文件夹大小时不会考虑这一点,这意味着大小可能看起来比实际更大。
您可以使用DISM工具找到WinSxS文件夹的真实大小。要找到实际大小,请启动提升的命令提示符(Command Prompt)并运行以下命令:
DISM.exe /Online /Cleanup-Image /AnalyzeComponentStore
该过程完成后,您将在“命令提示符(Command Prompt)”窗口中看到文件资源管理器报告的大小和实际大小:
如何清理 WinSxS 文件夹?
清理组件存储可以释放硬盘驱动器上的宝贵存储空间。
但是,您不能手动删除WinSxS文件夹。(WinSxS)另外,请注意,一旦您清理了WinSxS文件夹,您将无法回滚更新,直到您更新了您的 PC。
如果某些应用程序在清理过程中被删除,您可能还会遇到依赖于以前版本的DLL文件的应用程序的问题。(DLL)
如下图所示,有几种方法可以清理WinSxS文件夹。
使用 DISM 清理 WinSxS
DISM(部署映像服务和管理(Deployment Image Servicing and Management))是一个命令行实用程序,带有用于清理组件存储的内置选项。使用DISM进行清理将从WinSxS目录中删除所有不必要的文件,而不会中断系统的运行。
- 首先启动提升的命令提示符(Command Prompt)。按Win + R,键入cmd,然后按Ctrl + Shift + Enter。
- 在命令提示符(Command Prompt)中键入以下命令:
DISM.exe /Online /Cleanup-Image /AnalyzeComponentStore
- 该过程完成后,检查Component Store Cleanup Recommended旁边是否显示Yes或No。
- 如果它说是,请运行以下命令:
DISM.exe /Online /Cleanup-Image /StartComponentCleanup
该过程完成后,它将清除所有不必要的WinSxS文件。
当您想要清理特定的文件组时,还可以运行其他WinSxS清理命令。(WinSxS)例如,如果要清理旧的Windows组件版本,请运行以下命令:
DISM.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase
如果您运行的是旧版本的Windows ,例如Windows 7,您可以使用以下命令删除服务包备份(Windows 8、10(Windows 8)和 11 没有服务包):
DISM.exe /Online /Cleanup-Image /StartComponentCleanup /SPSuperseded
使用磁盘清理清理 WinSxS
Windows还具有内置的磁盘清理(Disk Cleanup)工具,可以清理系统文件(clean up system files)和其他类型的不必要文件,包括WinSxS文件夹中的文件。
- 启动文件资源管理器(File Explorer)并转到此 PC(或Windows 11上的计算机(Computer))。
- 选择本地磁盘(Local Disk )并按Alt + Enter打开磁盘属性。
- 选择常规(General)选项卡,然后单击磁盘清理(Disk Cleanup)选项。
- Windows将寻找您可以安全清理的文件,包括备份文件、临时文件和从旧版本Windows中保留的文件。当您看到磁盘清理(Disk Cleanup)窗口打开时,单击底部的清理系统文件按钮。(Clean up system files)
- 该实用程序将运行另一个搜索,这次是系统文件。一旦找到可以安全删除的文件,您将看到一个包含文件类型的列表。您将看到的常用名称包括(Common)Windows Update Cleanup、Microsoft Defender Antivirus和Temporary Internet Files。
如果要清理整个系统中的垃圾,可以选中所有复选框,但请务必选择Windows Update Cleanup以清理(Windows Update Cleanup)WinSxS文件夹中的更新文件。选择后单击(Click) 确定(OK)。
当然,随着时间的推移,文件会再次堆积在WinSxS文件夹中。因此,您需要不时使用磁盘清理(Disk Cleanup)来保持WinSxS文件夹清洁。或者,您可以使用Task Scheduler(Task Scheduler)安排组件清理。
使用任务计划程序清理 WinSxS
如果您想采取“设置它,忘记它”的方法来定期清理WinSxS文件夹,您可以使用任务计划程序。(use the Task Scheduler)
- 按Win + R,键入taskschd.msc,然后按Enter。
- 使用左侧边栏导航到Task Scheduler Library\Microsoft\Windows\Servicing。
- 右键单击任务列表中的StartComponentCleanup任务,选择Properties,然后切换到属性中的Triggers选项卡。然后,单击新建(New)。
- 通过选择频率(每天/每月/每周)和时间来选择任务的计划。完成后单击确定(OK)。
- 该任务将根据您添加的计划自动运行。但是,您也可以通过选择StartComponentCleanup任务并从右侧边栏中选择运行来立即运行该任务。(Run)
需要更多的空间?
如果您想在硬盘驱动器上腾出一些空间,清理WinSxS文件夹是一个很好的开始。您还可以通过卸载(uninstalling apps)不使用的应用程序或将大型个人文件移动到外部硬盘驱动器来腾出更多空间。
如果您正在寻找更多在Windows计算机上腾出空间的方法,我们提供了有关释放磁盘空间的几种方法(ways to free up disk space)的教程,这些方法可能会有所帮助。
What Is the WinSxS Folder, Why Is It Huge, and How to Cleanup?
A Windows user’s pυrsuit of storage is nevеr-ending. Cleаn up the PC in January, and your storage space will max out again before springtime. As you dіg deeper to find what’s conѕuming that disk space, you’re likely to come across the WinSxS folder on your Windows computer.
What Is the WinSxS folder?
WinSxS (short for “Windows Side by Side”) is a folder (location: C:\Windows\WinSxS) where Windows stores files required for installing Windows and backups or versions of those files.
Whenever you need to recover system files or add or remove Windows features, this is where Windows will search for the files required to perform an action. This is why it’s also called the component store.
WinSxS also stores files needed to install quality updates and previous versions of Windows components. These files allow you to revert back to the last state in case the update becomes troublesome.
WinSxS continues to increase in size over time because it will continue storing more component versions.
What Is the Correct Size of WinSxS?
The size of the WinSxS folder is usually calculated inaccurately by the File Explorer.
Files inside the WinSxS folder may appear in several places in the operating system. However, there’s usually only one copy of a file, while the rest of the files are hard links.
File Explorer doesn’t factor this in when calculating the size of folders, meaning the size can appear larger than it really is.
You can find the true size of the WinSxS folder using the DISM tool. To find the real size, launch an elevated Command Prompt and run the following command:
DISM.exe /Online /Cleanup-Image /AnalyzeComponentStore
Once the process completes, you’ll see both the size reported by the file explorer and the actual size in the Command Prompt window:
How to Cleanup WinSxS Folder?
Cleaning the component store can free up valuable storage on your hard drive.
However, you can’t delete the WinSxS folder manually. Also, note that once you clean up the WinSxS folder, you won’t be able to roll back updates until you’ve updated your PC.
You might also face issues with certain apps that rely on a previous version of a DLL file if it gets deleted during the cleanup.
As illustrated below, there are several ways to clean up the WinSxS folder.
Cleanup WinSxS Using DISM
DISM (Deployment Image Servicing and Management) is a command-line utility with a built-in option for cleaning up the component store. A cleanup using DISM will remove all the unnecessary files from the WinSxS directory without disrupting your system’s functioning.
- Start by launching an elevated Command Prompt. Press Win + R, type cmd, and press Ctrl + Shift + Enter.
- Type the following command in the Command Prompt:
DISM.exe /Online /Cleanup-Image /AnalyzeComponentStore
- Once the process completes, check if it says Yes or No next to Component Store Cleanup Recommended.
- If it says yes, run the following command:
DISM.exe /Online /Cleanup-Image /StartComponentCleanup
When the process completes, it will have cleaned all unnecessary WinSxS files.
There are also other WinSxS cleanup commands you can run when you want to clean up a specific group of files. For instance, if you want to clean up older Windows component versions, run the following command:
DISM.exe /Online /Cleanup-Image /StartComponentCleanup /ResetBase
If you’re running an older version of Windows like Windows 7, you can use the following command to remove service pack backups (Windows 8, 10, and 11 don’t have service packs):
DISM.exe /Online /Cleanup-Image /StartComponentCleanup /SPSuperseded
Cleanup WinSxS Using Disk Cleanup
Windows also has a built-in Disk Cleanup tool that can clean up system files and other types of unnecessary files, including ones in the WinSxS folder.
- Launch the File Explorer and go to This PC (or Computer on Windows 11).
- Select the Local Disk and press Alt + Enter to open disk properties.
- Select the General tab and click the Disk Cleanup option.
- Windows will look for files you can clean up safely, including backup files, temporary files, and files retained from older versions of Windows. When you see the Disk Cleanup window open, click the Clean up system files button at the bottom.
- The utility will run another search, this time for system files. Once it finds the files that can be deleted safely, you’ll see a list with the types of files. Common names you’ll see include Windows Update Cleanup, Microsoft Defender Antivirus, and Temporary Internet Files.
You can check all boxes if you want to clean up junk from the entire system, but be sure to select Windows Update Cleanup for cleaning up the update files from the WinSxS folder. Click OK once selected.
Of course, over time, the files will accumulate in the WinSxS folder again. So you’ll need to use Disk Cleanup every once in a while to keep the WinSxS folder clean. Alternatively, you can schedule component cleanup using the Task Scheduler.
Cleanup WinSxS Using Task Scheduler
You can use the Task Scheduler if you want to take a “set it, forget it” approach to regularly clean the WinSxS folder.
- Press Win + R, type taskschd.msc, and press Enter.
- Use the left sidebar to navigate to Task Scheduler Library\Microsoft\Windows\Servicing.
- Right-click on the StartComponentCleanup task from the task list, select Properties, and switch to the Triggers tab in properties. Then, click on New.
- Select a schedule for the task by selecting the frequency (daily/monthly/weekly) and a time. Click OK when done.
- The task will run automatically as per the schedule you’ve added. However, you can also run the task right away by selecting the StartComponentCleanup task and selecting Run from the right sidebar.
Need More Space?
If you’re trying to make some space on your hard drive, cleaning up the WinSxS folder is a great start. You can also make more space by uninstalling apps you don’t use or moving large personal files to an external hard drive.
If you’re looking for more ways to make space on your Windows computer, we have a tutorial on several ways to free up disk space that might help.