一个让人痛苦想删不敢的文件夹winsxx


WinSxS Folder in Windows 7 / 8 explained

Most of you may have noticed the WinSxS folder in Windows 7 or Windows 8 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 8, Windows 7 and Windows Vista, is intriguing, to many ! Check the image below.

winsxs-folder-windows

So what is the mystery of this Winsxs folder in Windows Vista and later? Let us find so, in this post.

The Winsxs folder, stores multiple copies of dll‘s in order to let multiple applications run in Windows without any compatibility problem. If you browse inside, you will see what look like a lot of duplicate dlls, 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 folder Windows 7 / 8

In short, Winsxs, which stands for ‘Windows Side By Side’, is Windows native assembly cache. Libraries which 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.

Sub-folders of WinSxS

Again, as can be seen in the image below, in the Winsxs folder, the ‘Other’ File types takes the bulk of the space. These primarily consist of .imd, .ngr, .csd, .dll, .dll.mui, .exe and such other file types.

File Types in WinSxS

In Windows 7, 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 which 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”.

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 dll‘s 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.

So 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 which 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 advice 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 problem.

WinSxs Folder Cleanup

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.

In Windows 8, open Disk Cleanup Tool and use the Windows Update Cleanup option to clean the WinSxs.

Microsoft released an Update that added the Windows Update Cleanup option to Disk Cleanup tool in Windows 7.

You can now also clean up WinSxS in Windows Server 2008 R2 with new the new Update.

Here are some other options you may consider to free up disk space – some routine and some extreme:

  1. Run Disk Cleanup tool or CCleaner
  2. Uninstall unused applications
  3. Move Page file to another drive
  4. Disable hibernation
  5. Use the dedicated dump file option to capture memory dump files on another volume on the system.
  6. Disable system restore points
  7. 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 and Windows 7 / Vista 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 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 actually consumed in a directory is definitely 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!点击打开链接

Post ported from WVC.

Additional reads:

Posted by AnandK@TWC on September 1, 2013 , in Category Windows with Tags
Anand Khanse aka HappyAndyK is an end-user Windows enthusiast, a Microsoft MVP in Windows, since 2006, and the Admin of TheWindowsClub.com. Please create a System Restore Point before trying out any software & be careful about any third-party offers while installing freeware.


这个清理工具我没试过:

http://www.cnblogs.com/BigTall/archive/2009/09/30/1577091.html


因为磁盘空间不够了,所以想起来清理一下系统垃圾文件,主要目标就是臭名昭著的winsxs目录。这个winsxs就是微软为了解决“dll hell”问题,结果是好比在windows系统里安置了一个毫无节制不断增大的“肿瘤”。听说微软研究院现在在研究这个问题,不过我想我的硬盘空间不够大,等不到这个补丁出来的时候,所以只好自己动手了。

winsxs目录下的文件都是系统要用的各种库文件,system32下存放了这些dll的最新的版本,所有老版本的dll都放在winsxs下。所以只要你安装程序或者更新补丁,system32下的文件就会被更新,而同时winsxs就会增加一些旧文件,所以我们的C盘空间就在持续不断地减少,直到磁盘容量不够,被迫重装系统为止,如果你足够幸运,可以直接安装最新的SP的话,或许可以为winsxs节约一点微薄的空间。

winsxs目录下的不同版本文件都存放在特定命名规则的目录下,比如

C:\Windows\winsxs>dir msil_microsoft.transactions.bridge.resources*
驱动器 C 中的卷是 vista
卷的序列号是 989F-EFF3

C:\Windows\winsxs 的目录

msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6000.16386_zh-cn_1cde5a17d78fb5ec
msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6000.16716_zh-cn_1cd75781d79605cf
msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6000.20876_zh-cn_060fb27df137fddf
msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6001.18000_zh-cn_1cb2dbd3d7e75eb8
msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6001.18106_zh-cn_1cb252ffd7e7f8cf
msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6001.22221_zh-cn_05e71ebbf18d0b5e
msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6002.18005_zh-cn_1c8e610fd838f2cc
               0 个文件              0 字节
               7 个目录  5,382,139,904 可用字节

这里的各个部分用下划线分割,其中我们关注的是“6.0.6000.16386”部分,它表示旧文件的版本号,之前则是唯一文件标识,之后是语言,最后部分是散列值(防止名字冲突)。

本工具的设计思想就是删除所有的旧文件。所有满足如下全部条件的目录都会被移动到C:\Windows\winsxs_del目录中。

  1. 存在比自身更新的版本
  2. 本身不是最新版本

运行工具前的C盘剩余空间:

     所列文件总数:
            4473 个文件  3,336,376,627 字节
            7655 个目录    326,840,320 可用字节

C:\Windows\winsxs_del>

 

运行工具并且执行命令

for /d %v in (%SystemRoot%\winsxs_del\*.*) do rd /s /q %v

1@echo off
 2rem 获取windows版本
 3set move_dir=%SystemRoot%\winsxs_del
 4if not exist %move_dir%\nul md %move_dir%
 5set winver=none
 6FOR /F "eol=; tokens=4* delims=] " %%i in ('ver') do set winver=%%i
 7if "%winver%" == "none" goto enover
 8echo windows version is %winver%, ready to list winsxs dir.
 9if not exist %SystemRoot%\winsxs\nul goto enosxs
11set ver_prefix=%winver:~0,-1%
12echo list winsxs finished! now ready to clear duplicated files 
13echo dir /ad %SystemRoot%\winsxs\*_%ver_prefix%*
15if "%1" == "run-winsxs-generated" goto :lSkipGen
16rem 准备生成代码
17copy /y "%~f0" "%temp%\%~nx0" > nul
18echo rem genereted code here >> "%temp%\%~nx0"
19echo :ldcdStat1 >> "%temp%\%~nx0"
20echo set end4=%%arg:%ver_prefix%=%%>> "%temp%\%~nx0"
21echo goto ldcdStat2 >> "%temp%\%~nx0"
22echo :ldcdStat3 >> "%temp%\%~nx0"
23echo set end4a=%%arg:%winver%=%%>> "%temp%\%~nx0"
24echo goto ldcdStat4 >> "%temp%\%~nx0"
25rem notepad "%temp%\%~nx0"
26"%temp%\%~nx0" run-winsxs-generated
27goto :EOF
29:lSkipGen
30FOR /F "eol=; tokens=1-4 delims= " %%a in ('dir /ad %SystemRoot%\winsxs\*_%ver_prefix%*') do (
   if "%%c" == "<DIR>" call:fnDoClear %%d
32)
34echo clear OK!
35goto :EOF
37:enover
38echo could not get windows version, abort!
39goto :EOF
41:enosxs
42echo not found %SystemRoot%\winsxs! maybe no privilege or lower windows!
43echo only support windows XP and later!
44goto :EOF
46:fnDoClear
47rem arg: dir_name
48FOR /F "eol=; tokens=1-14 delims=_" %%g in ("%1") do call:fnDoClearDir %1 %%g %%h %%i %%j %%k %%l %%m %%n %%o %%p %%q %%r %%s %%t %%u %%v %%w %%x %%y %%z
49goto :EOF
51:fnDoClearDir 
52rem arg: dir_name dir_parts 
53set d_name=%1
54rem 检查参数是否匹配 %winver%, 先跳过前两个.同时准备组合新版本匹配名称,nv1存当前版本,nv2存当前的前一个版本
55set nv1=%2_%3_
56set nv2=%2_%3_
57:ldcdCycle
58if "%4" == "" goto :EOF
59rem 检查是否 ver_prefix 开头,如果是则继续检查是否winver,如果不是winver则表示目标存在
60set arg=%4
61rem set line=set end4=%%arg:%ver_prefix%=%%
62rem %line%
63goto ldcdStat1
64:ldcdStat2
65if "%arg%" == "%end4%" goto ldcdNext
66rem 检查是否 winver 开头
67rem set line=set end4a=%%arg:%winver%=%%
68rem %line%
69goto ldcdStat3
70:ldcdStat4
71if not "%arg%" == "%end4a%" goto :EOF
72rem 至此则为 ver_prefix 开头 且 不等于 winver 的目录名,检查最新版本是否存在,存在则可删除旧的
73set newfound=false
74for /d %%v in ("%SystemRoot%\winsxs\%nv1%%winver%.*_%5_*") do (
   if exist %%v\nul set newfound=true
76)    
77if "%newfound%" == "true" call:fnDelDir %d_name%
79goto :EOF
80:ldcdNext
81set nv2=%nv1%
82set nv1=%nv2%%4_
83shift
84goto ldcdCycle
86:fnDelDir
87rem arg: dir
88echo del %SystemRoot%\winsxs\%1
89takeown /r /f "%SystemRoot%\winsxs\%1"
90cacls "%SystemRoot%\winsxs\%1" /t /e /g everyone:f
91move "%SystemRoot%\winsxs\%1" "%move_dir%\%1"
92goto :EOF
94

删除所有可以删除的无用文件之后的剩余空间:

     所列文件总数:
              52 个文件      7,555,048 字节
             131 个目录  5,383,979,008 可用字节

C:\Windows\winsxs_del>

 

工具源代码如下:请保存为winsxs_clear.bat即可。所有不再需要的文件会移动到c:\windows\winsxs_del目录中,可以直接进行删除。

执行时候,务必请使用“管理员”权限。



  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
winsxs目录下的文件都是系统要用的各种库文件,system32下存放了这些dll的最新的版本,所有老版本的dll都放在winsxs下。所以只要你安装程序或者更新补丁,system32下的文件就会被更新,而同时winsxs就会增加一些旧文件,所以我们的C盘空间就在持续不断地减少,直到磁盘容量不够,被迫重装系统为止,如果你足够幸运,可以直接安装最新的SP的话,或许可以为winsxs节约一点微薄的空间。 winsxs目录下的不同版本文件都存放在特定命名规则的目录下,比如 C:\Windows\winsxs>dir msil_microsoft.transactions.bridge.resources* 驱动器 C 中的卷是 vista 卷的序列号是 989F-EFF3 C:\Windows\winsxs 的目录 msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6000.16386_zh-cn_1cde5a17d78fb5ec msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6000.16716_zh-cn_1cd75781d79605cf msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6000.20876_zh-cn_060fb27df137fddf msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6001.18000_zh-cn_1cb2dbd3d7e75eb8 msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6001.18106_zh-cn_1cb252ffd7e7f8cf msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6001.22221_zh-cn_05e71ebbf18d0b5e msil_microsoft.transactions.bridge.resources_b03f5f7f11d50a3a_6.0.6002.18005_zh-cn_1c8e610fd838f2cc 0 个文件 0 字节 7 个目录 5,382,139,904 可用字节 这里的各个部分用下划线分割,其中我们关注的是“6.0.6000.16386”部分,它表示旧文件的版本号,之前则是唯一文件标识,之后是语言,最后部分是散列值(防止名字冲突)。 本工具的设计思就是除所有的旧文件。所有满足如下全部条件的目录都会被移动到C:\Windows\winsxs_del目录中。 1.存在比自身更新的版本 2.本身不是最新版本 运行工具前的C盘剩余空间: 所列文件总数: 4473 个文件 3,336,376,627 字节 7655 个目录 326,840,320 可用字节 C:\Windows\winsxs_del> 运行工具并且执行命令 for /d %v in (%SystemRoot%\winsxs_del\*.*) do rd /s /q %v 除所有可以除的无用文件之后的剩余空间: 所列文件总数: 52 个文件 7,555,048 字节 131 个目录 5,383,979,008 可用字节 C:\Windows\winsxs_del> 工具源代码如下:请保存为winsxs_clear.bat即可。所有不再需要的文件会移动到c:\windows\winsxs_del目录中,可以直接进行除。 执行时候,务必请使用“管理员”权限。 1@echo off 2rem 获取windows版本 3set move_dir=%SystemRoot%\winsxs_del 4if not exist %move_dir%\nul md %move_dir% 5set winver=none 6FOR /F "eol=; tokens=4* delims=] " %%i in ('ver') do set winver=%%i 7if "%winver%" == "none" got

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值