大多数人可能已经注意到Windows 11/10/8/7WinSxS 文件夹(WinSxS folder),并对其大小感到惊讶。对于那些没有的人,该文件夹位于C:\Windows\Winsxs并且具有惊人的大小!我的几乎是 5 GB,有大约 6000 个文件夹和 25000 个文件,几乎占据了Windows文件夹的 40%!这个Winsxs文件夹的大小在 XP 中约为 25-50 MB;它在Windows 11(Windows 11)中的大尺寸。Windows 10、Windows 8、Windows 7 和Windows Vista对许多人来说都很有趣!检查下面的图像。
So what is the mystery of this Winsxs folder in Windows 11/10? Let us find so, in this post.
什么是Windows 11/10
WinSxS 文件夹(WinSxS folder),存放多份 dll、exe 及其他系统文件,让多个应用程序在Windows中运行而不会出现任何兼容性问题。如果你在里面浏览,你会看到很多重复的文件,每个文件都有相同的名称。这些实际上是存储的相同文件的不同版本;因为不同的程序可能需要不同的版本。
Winsxs代表“Windows Side By Side”,是Windows本地程序集缓存。由多个应用程序提供的库存储在那里。此功能在Windows ME中首次引入,被认为是微软对困扰(Windows ME)Windows 9x的所谓“dll 地狱”问题的解决方案。
在Winsxs中,“备份”文件夹是最大的,如下图所示。
同样,如下图所示,在Winsxs 文件夹中,“其他”文件(’ File)类型占据了大部分空间。这些主要包括.imd、.ngr、.csd、.dll、.dll.mui、.exe和其他此类文件类型。
在Windows 7及更高版本中,没有“dllcache”文件夹,也找不到“i386”文件夹,系统缓存(如在 XP 中)所有源模块。正是这个WinSxS文件夹存储了并排应用程序的共享组件。这些文件可以是同一程序集或应用程序的多个版本。每个并排的组件都有一个独特的身份。程序集标识的属性之一是它的版本。
“Side-by-side assemblies are used by the operating system as fundamental units of naming, binding, versioning, deployment, and configuration. The Winsxs folder includes all manifests, optional components, and 3rd party Win32 files”, says Microsoft.
但是,为什么有这么多子文件夹,为什么要保留 同一个 dll、exe 或其他文件的这么多不同版本?(so many)
如前所述,Windows将旧的 dll 和库组件存储在WinSxS 文件夹中。现在,如果此文件的较新版本是操作系统的一部分,但特定应用程序需要特定的旧版本才能运行,则将使用 WinSxS文件夹中的旧版本,将新版本留在当前位置,以供其他可能需要它的应用程序。
删除 WinSxS 文件夹是否安全?
显然,您不能删除此目录或将其移至别处。也不建议在此处删除任何内容,因为这样的步骤可能会使您的应用程序无法运行甚至破坏您的系统!如果您安装了许多应用程序,则可能会有一个超大大小的WinSxS文件夹。此 WinSxs 文件夹不能驻留在系统卷以外的任何其他卷上。这是因为NTFS硬链接。如果您尝试移动文件夹,可能会导致Windows更新、服务包、功能等无法正确安装。
如果您从WinSxS 文件夹中删除组件,例如清单或程序集等,您可能会遇到麻烦。Each system would react differently. What may work for one could break another!例如,如果您安装的程序需要您可能已删除的特定程序集,那么该程序将无法运行!压缩文件夹也是一个禁忌,因为它可能会在 Windows 更新期间或安装修补程序时导致问题。(Compressing the folder is also a no-no, as it could cause problems during WindowsUpdates or while installing a Hotfix.)
最安全的清理方法是卸载不需要的应用程序。但是,这也不是万无一失的,因为许多应用程序仍然在此处留下它们的文件,因为它们可能在其他应用程序之间共享。因此,遗留未使用的 dll 的概率非常高。
我们不建议使用 WinsxsLite 之类的 WinSxS 清理工具,因为您最终可能会破坏您的 Windows。(We would not advise the use of WinSxS cleanup tools like WinsxsLite as you could end up breaking your Windows.)
而如果你喜欢尝试新软件或频繁安装卸载,你可能会注意到你的Winsxs 体积确实很大,因为Windows会存储这些 dll 文件的多个副本,以便让多个应用程序没有兼容性问题。
(WinSxS Folder Cleanup)Windows 11/10中的WinSxS 文件夹清理
Windows 8.1为(Windows 8.1)DISM.exe引入了一个新的命令行选项/AnalyzeComponentStore。运行此命令,将分析WinSxS文件夹并告诉您是否建议使用Component Store Cleanup。它也存在于Windows 11/10中。
- 在Windows 11/10/8.1/8中,打开磁盘清理工具(Disk Cleanup Tool)并使用Windows 更新清理(Windows Update Cleanup)选项清理WinSxS。
- 对于Windows 7,Microsoft发布了一个更新,将 Windows Update Cleanup 选项添加到磁盘清理工具中。
- Windows Server用户现在还可以使用新的更新来清理Windows Server 中的 WinSxS 。
以下是您可以考虑释放磁盘空间(free up disk space)的其他一些选项- 一些常规和一些极端:
- 运行磁盘清理工具(Disk Cleanup tool)
- 卸载未使用的应用程序
- 将页面文件移动到另一个驱动器
- 禁用休眠
- 使用专用转储文件选项来捕获系统上另一个卷上的内存转储文件。
- 禁用系统还原点
- (Offload)将用户配置文件和程序文件目录卸载到系统上的另一个卷。
来自 TechNet 博客的更新 1:(Update 1 From TechNet Blogs:)以前版本的Windows之间最大的变化之一是从INF描述的操作系统转向组件化。操作系统中的所有组件都可以在WinSxS文件夹中找到——实际上,我们将此位置称为组件存储。每个组件都有一个唯一的名称,其中包括为其构建的版本、语言和处理器架构。WinSxS文件夹是在系统上找到组件的唯一位置,您在系统上看到的所有其他文件实例都是通过来自组件存储的硬链接“投影”的。
既然您知道商店为什么会变得如此之大,那么您的下一个问题可能是问我们为什么不删除旧版本的组件。对此的简短回答是可靠性。组件存储以及系统上的其他信息使我们能够在任何给定时间确定项目组件的最佳版本是什么。这意味着,如果您卸载安全更新,我们可以在系统上安装下一个最高版本——我们不再有“乱序卸载”问题。这也意味着,如果您决定安装可选功能,我们不仅会选择组件的RTM版本,还会查看系统上可用的最高版本是什么。
安全减小WinSxS文件夹大小的唯一方法是减少系统可以采取的一系列可能的操作——最简单的方法是首先删除安装组件的包。这可以通过卸载系统上已被取代的软件包版本来完成。Service Pack 1包含一个名为VSP1CLN.EXE的二进制文件,该工具将使Service Pack包在您的系统上永久(不可删除),并删除所有被取代组件的RTM版本。这只能通过使Service Pack永久化来实现;我们可以保证我们永远不需要RTM版本。
来自 E7 博客(From E7 Blogs)的更新 2 :“模块化(Modularizing)”操作系统是Windows Vista的工程目标。这是为了解决旧版Windows中与安装、服务和可靠性相关的许多问题。Windows SxS 目录代表所有系统组件的“安装和服务状态” 。但实际上,它实际上并没有像使用内置工具(DIR和Explorer)来测量使用的磁盘空间时那样消耗磁盘空间。我们让您很难知道目录中消耗了多少空间这一事实是公平的!WinSxS目录还支持脱机服务,并使Windows Vista及更高版本“可安全用于映像”。
已经有好几篇博客甚至一些“地下”工具告诉你删除WinSxS 目录就可以了,而且安装后可以将其从系统中删除肯定是真的. 但如上所述,这是一种非常糟糕的做法,因为您正在删除可靠服务的能力、所有操作系统组件以及在系统上更新或配置可选组件的能力。Windows 仅支持其原始安装位置的物理驱动器上的WinSxS目录。(WinSxS)
结论(Conclusion)
让 WinSxS 文件夹保持原样!
在此处了解Sysnative 文件夹、 Panther 文件夹(Panther folder)以及Catroot 和 Catroot2 文件夹(Catroot & Catroot2 folders)。(Learn about the Sysnative folder, Panther folder and Catroot & Catroot2 folders here.)
补充阅读:(Additional reads:)
Analyze Windows Component Store or WinSxS in Windows
WinSxS folder cleanup in Windows
Add Windows Update Cleanup option to Disk Cleanup tool in Windows
Clean up WinSxS Directory on Windows Server
WinSxS Folder in Windows 11/10 explained
Most of you may have noticed thе WinSxS folder in Windows 11/10/8/7 and been surprised at its size. For those who have not, the folder is situated at C:\Windows\Winsxs and has a whopping size! Mine is almost 5 GB and has around 6000 folders & 25000 files and occupies almost 40% of the Windows folder! While the size of this Winsxs folder, in XP, is around 25-50 MB; its large size in Windows 11. Windows 10, Windows 8, Windows 7, and Windows Vista, is intriguing to many! Check the image below.
So what is the mystery of this Winsxs folder in Windows 11/10? Let us find so, in this post.
What is WinSxS folder in Windows 11/10
The WinSxS folder, stores multiple copies of dll, exe, and other system files to let multiple applications run in Windows without any compatibility problem. If you browse inside, you will see what looks like a lot of duplicate files, each having the same name. These are actually, different versions of the same files which are being stored; as different programs may require different versions.
Winsxs, which stands for ‘Windows Side By Side’, is Windows native assembly cache. Libraries that are being by multiple applications are stored there. This feature was first introduced, in Windows ME and was considered as Microsoft’s solution to the so-called ‘dll hell’ issues that plagued Windows 9x.
In Winsxs, the ‘backup’ folder is the largest, as can be noticed in the image below.
Again, as can be seen in the image below, in the Winsxs folder, the ‘Other’ File types take the bulk of the space. These primarily consist of .imd, .ngr, .csd, .dll, .dll.mui, .exe and such other file types.
In Windows 7 and later, there isn’t a ‘dllcache’ folder and nor can you find the ‘i386’ folder, where the system caches (like in XP) all it’s source modules. It is this WinSxS folder that stores the shared components of side-by-side applications. These files can be multiple versions of the same assembly or application. Every side-by-side assembly has a unique identity. One of the attributes of the assembly identity is its version.
“Side-by-side assemblies are used by the operating system as fundamental units of naming, binding, versioning, deployment, and configuration. The Winsxs folder includes all manifests, optional components, and 3rd party Win32 files”, says Microsoft.
But, why so many subfolders and why keep so many different versions of the same dll, exe, or other files?
As mentioned, Windows stores the old dlls and library components in the WinSxS folder. Now if a newer version of this file is a part of the OS, but a particular application requires a particular older version for running, then the older version from the WinSxS folder will be used, leaving the newer version in its present place, for other applications which may require it.
Is it safe to delete WinSxS folder?
Obviously, you cannot delete this directory or move it elsewhere. Nor is it advisable to delete anything here, as such a step could probably make your applications un-workable or even break your system! If you have many applications installed, you can expect to have a jumbo-sized WinSxS folder. This WinSxs folder cannot reside on any other volume than the system volume. This is because of the NTFS hard links. If you try to move the folder, it may result in Windows updates, service packs, features, etc., not installing correctly.
If you delete components from the WinSxS folder like the manifests or the assemblies, etc., you could be in trouble. Each system would react differently. What may work for one could break another! For instance, if you install a program that requires that particular assembly, which you may have deleted, then that program will just not run! Compressing the folder is also a no-no, as it could cause problems during WindowsUpdates or while installing a Hotfix.
The safest way to clean it is by simply uninstalling applications that you don’t require. However, this, too, is not fool-proof, as many applications still leave behind their files here, since they may be shared between other applications. So the probability of dud unused dll‘s being left behind is quite high.
We would not advise the use of WinSxS cleanup tools like WinsxsLite as you could end up breaking your Windows.
And if you are into trying out new software or installing and uninstalling frequently, you may notice that your Winsxs size is indeed large, as Windows will store multiple copies of these dll files, in order to let multiple applications without compatibility problems.
WinSxS Folder Cleanup in Windows 11/10
Windows 8.1 introduced a new command-line option for DISM.exe, /AnalyzeComponentStore. Running this command, will analyze the WinSxS folder and tell you whether a Component Store Cleanup is recommended or not. It is present in Windows 11/10, as well.
- In Windows 11/10/8.1/8, open Disk Cleanup Tool and use the Windows Update Cleanup option to clean the WinSxS.
- For Windows 7, Microsoft released an update that added the Windows Update Cleanup option to the Disk Cleanup tool.
- Windows Server users can now also clean up WinSxS in Windows Server with new the new Update.
Here are some other options you may consider to free up disk space – some routine and some extreme:
- Run Disk Cleanup tool
- Uninstall unused applications
- Move Page file to another drive
- Disable hibernation
- Use the dedicated dump file option to capture memory dump files on another volume on the system.
- Disable system restore points
- Offload user profile and program file directories to another volume on the system.
Update 1 From TechNet Blogs: One of the largest changes between previous versions of Windows was a move from an INF described OS to componentization. All of the components in the operating system are found in the WinSxS folder – in fact, we call this location the component store. Each component has a unique name that includes the version, language, and processor architecture that it was built for. The WinSxS folder is the only location that the component is found on the system, all other instances of the files that you see on the system are “projected” by hard linking from the component store.
Now that you know why the store can grow to be so large, your next question is probably to ask why we don’t remove the older versions of the components. The short answer to that is reliability. The component store, along with other information on the system, allows us to determine at any given time what the best version of a component to the project is. That means that if you uninstall a security update, we can install the next highest version on the system – we no longer have an “out of order uninstall” problem. It also means that if you decide to install an optional feature, we don’t just choose the RTM version of the component, we’ll look to see what the highest available version on the system is.
The only way to safely reduce the size of the WinSxS folder is to reduce the set of possible actions that the system can take – the easiest way to do that is to remove the packages that installed the components in the first place. This can be done by uninstalling superseded versions of packages that are on your system. Service Pack 1 contains a binary called VSP1CLN.EXE, a tool that will make the Service Pack package permanent (not removable) on your system, and remove the RTM versions of all superseded components. This can only be done because by making the Service Pack permanent; we can guarantee that we won’t ever need the RTM versions.
Update 2 From E7 Blogs: “Modularizing” the operating system was an engineering goal in Windows Vista. This was to solve a number of issues in legacy Windows related to installation, servicing, and reliability. The Windows SxS directory represents the “installation and servicing state” of all system components. But in reality, it doesn’t actually consume as much disk space as it appears when using the built-in tools (DIR and Explorer) to measure disk space used. The fact that we make it tricky for you to know how much space is consumed in a directory is a fair point! The WinSxS directory also enables offline servicing, and makes Windows Vista and later “safe for imaging”.
There have been several blogs and even some “underground” tools that tell you it’s ok to delete the WinSxS directory, and it’s certainly true that after installation, you can remove it from the system, and it will appear that the system boots and runs fine. But as described above, this is a very bad practice, as you’re removing the ability to reliably service, all operating system components and the ability to update or configure optional components on your system. Windows only supports the WinSxS directory on the physical drive in its originally installed location.
Conclusion
Let the WinSxS folder be as it is!
Learn about the Sysnative folder, Panther folder and Catroot & Catroot2 folders here.
Additional reads:
Analyze Windows Component Store or WinSxS in Windows
WinSxS folder cleanup in Windows
Add Windows Update Cleanup option to Disk Cleanup tool in Windows
Clean up WinSxS Directory on Windows Server