Slim down for the Windows 7 WinSxS directory, and be cautious.

Source: Internet
Author: User
Tags eol naming convention winsxs folder

Just use Win7 system soon, the previous time in cleaning up the system garbage, found that the Win7 System Windows folder WinSxS folder occupies a large space, want to clean up, but prompted no permissions can not clean. Then on the Internet to check the end, the original WinSxS is a large file warehouse, the system is located almost all of the system files are there at least one backup. And with the use of the system, the space occupied by WinSxS will continue to accumulate and grow, finally will devour the entire system partition disk space. The following is attached to a search for a specific descriptive narrative digest, WinSxS's slimming method and a description of the DLL hell problems described WinSxS Digest and share:

WinSxS's specific descriptive narrative abstracts:

***

WinSxS directory is located in the Windows root directory, is a very large file warehouse, the system is located in the partition almost all of the system files are there at least one backup. It is best to search the public video, public picture, public music directory files in WinSxS by searching function, you will find that the files that have been deleted when the system is streamlined are still able to find the shadow in WinSxS. If the system files are deleted or destroyed, the command Sfc/scannow can be restored, but the SFC command will be invalidated if WinSxS is removed from any of the important components. The process of online update of the system is the old version number of the file is replaced by the new version number, the old file itself backup in WinSxS; the process of uninstalling the patch is that the new version number of the system is replaced by the old version number, and the old version number file is the source of WinSxS. XP also has similar features, but the backup files under XP can be deleted directly, not Vista and Win7. As a result, the space occupied by Vista and Win7 will grow larger and larger with the update. WinSxS files are very important, it is recommended not to delete, in my long-term practical experience, temporarily found that only the Manifestcache and temp two directory cache files talent enough to safely delete.

Special reminder: All online streamlining winsxs methods have a certain criticality (except Microsoft's official tools), such as "Delete the backup directory or empty files in place of the same name", although it is called backup, but it is definitely not back-up files, but it is related to the system can be updated and normal " Turn on or turn off Windows features "key files, and some of the many reprinted articles are misleading. A software provides a way to remove Windows built-in fonts, help files, in fact this is no matter what the meaning of the lite system, fonts and Help files in WinSxS another backup, the two same files share a storage space, in other words, delete before and after delete C disk free space unchanged! Note, however, that if you look at the properties of a file or directory, they will occupy space. It is a good idea to delete one or more of the lower version number of the file with the same name in WinSxS, but the problem is that the different version numbers of the files with the same name are important and cannot be deleted, such as related components of the. Net Framework.

***

WinSxS Method of Slimming:

***


Gadgets to clean up WinSxS

Because the disk space is not enough, so think up to clean up the system junk file, the main target is the infamous WinSxS folder. This WinSxS is Microsoft in order to solve the "DLL Hell" problem, the result is like in the Windows system placed a no restraint ever-increasing "tumor." I heard that Microsoft Research is now studying this issue, but I think my hard disk space is not large enough to wait until this patch comes out, so just good myself.

WinSxS folder files are all the system to use the various library files, system32 the latest version of these DLLs, all the old version number of DLLs are placed under WinSxS. So just to install the program or update the patch, system32 files will be updated, and at the same time WinSxS will add some old files, so our C disk space is continuously reduced until the disk capacity is not enough, forced to reinstall the system, assuming you are lucky enough, The ability to install the latest SP directly may save a little bit of space for WinSxS.

The different version number files under the WinSxS folder are stored under the folder for a specific naming convention, for example

C:/windows/winsxs>dir msil_microsoft.transactions.bridge.resources*
The volume in drive C is Vista
The serial number of the volume is 989F-EFF3

C:/windows/winsxs's Folder

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 Files 0 bytes
7 Folders 5,382,139,904 bytes available

The sections here are cut with underscores, and we focus on the "6.0.6000.16386" section, which represents the version number of the old file, preceded by the unique file identifier, followed by the language, and finally the hash value (preventing name collisions).

The idea of this tool is to delete all old files. All folders that meet all of the following conditions will be moved to the C:/windows/winsxs_del folder.
There is a version number that is newer than itself
itself is not the latest version number

The remaining space on the C disk before executing the tool:

Total Files Listed:
4,473 files 3,336,376,627 bytes
7,655 folders 326,840,320 bytes available

C:/windows/winsxs_del>



Execute the tool and execute the command

FOR/D%v in (%systemroot%/winsxs_del/*.*) do rd/s/q%v

Remove the remaining space after all the useless files that can be deleted:

Total Files Listed:
52 Files 7,555,048 bytes
131 Folders 5,383,979,008 bytes available

C:/windows/winsxs_del>



Tool source code such as the following: Please save as Winsxs_clear.bat can. All files that are no longer needed are moved to the C:/windows/winsxs_del folder and can be deleted directly.

When executing, be sure to use the "administrator" permission.
@echo off
REM Gets the Windows version number
Set Move_dir=%systemroot%/winsxs_del
If not exist%move_dir%/nul MD%move_dir%
Set Winver=none
For/f "eol=; tokens=4* delims=] "%%i in (' ver ') do set winver=%%i
If "%winver%" = = "None" Goto enover
echo Windows version is%winver%, ready to list WinSxS dir.
If not exist%systemroot%/winsxs/nul goto Enosxs

Set ver_prefix=%winver:~0,-1%
echo List WinSxS finished! Now ready to clear duplicated files
Echo Dir/ad%systemroot%/winsxs/*_%ver_prefix%*

If "%1" = = "run-winsxs-generated" Goto:lskipgen
REM Ready to generate code
copy/y "%~f0" "%temp%/%~nx0" > Nul
echo rem genereted code here >> "%temp%/%~nx0"
ECHO:LDCDSTAT1 >> "%temp%/%~nx0"
echo Set end4=%%arg:%ver_prefix%=%%>> "%temp%/%~nx0"
Echo Goto ldcdStat2 >> "%temp%/%~nx0"
ECHO:LDCDSTAT3 >> "%temp%/%~nx0"
echo Set end4a=%%arg:%winver%=%%>> "%temp%/%~nx0"
Echo Goto ldcdStat4 >> "%temp%/%~nx0"
REM Notepad "%temp%/%~nx0"
"%temp%/%~nx0" run-winsxs-generated
Goto:eof

: Lskipgen
For/f "eol=; Tokens=1-4 delims= "%%a in (' Dir/ad%systemroot%/winsxs/*_%ver_prefix%* ') does (
If "%%c" = = "<DIR>" Call:fndoclear%%d
)

Echo Clear ok!
Goto:eof

: Enover
Echo could not get Windows version, abort!
Goto:eof

: Enosxs
Echo Not found%systemroot%/winsxs! Maybe no privilege or lower windows!
echo only support Windows XP and later!
Goto:eof

: Fndoclear
REM Arg:dir_name
For/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
Goto:eof

: Fndocleardir
REM Arg:dir_name Dir_parts
Set d_name=%1
REM Check if the parameters match%winver%, skip the first two first. At the same time, prepare to combine the new version number match name, NV1 the current version number, Nv2 save the current previous version number
Set nv1=%2_%3_
Set nv2=%2_%3_
: ldcdcycle
If "%4" = = "" Goto:eof
REM checks whether the Ver_prefix begins, assuming that the check is winver, assuming that the target is not winver
Set arg=%4
REM Set Line=set end4=%%arg:%ver_prefix%=%%
REM%line%
Goto LDCDSTAT1
: LDCDSTAT2
If "%arg%" = = "%end4%" goto Ldcdnext
REM Check whether Winver begins
REM Set Line=set end4a=%%arg:%winver%=%%
REM%line%
Goto LDCDSTAT3
: LDCDSTAT4
If not "%arg%" = = "%end4a%" goto:eof
REM This is the folder name that starts with Ver_prefix and is not equal to winver, checks whether the latest version number exists, or deletes the old
Set Newfound=false
FOR/D%%v in ("%systemroot%/winsxs/%nv1%%winver%.*_%5_*") Do (
If exist%%v/nul set newfound=true
)
If "%newfound%" = = "true" Call:fndeldir%d_name%

Goto:eof
: Ldcdnext
Set nv2=%nv1%
Set nv1=%nv2%%4_
Shift
Goto Ldcdcycle

: Fndeldir
REM Arg:dir
Echo del%systemroot%/winsxs/%1
TAKEOWN/R/F "%systemroot%/winsxs/%1"
cacls "%systemroot%/winsxs/%1"/t/e/g everyone:f
Move "%systemroot%/winsxs/%1" "%move_dir%/%1"
Goto:eof



Code guidance to help you understand the program and algorithm, but the main batch processing syntax is not said, a few years of programming experience I would like to understand. Here are a few of the areas to note:
The first part of the code is to get the system version number with the Ver command, and store it in the%winver% variable, for example, my ver command returns "Microsoft Windows [version number 6.0.6002]", in order to get this "6.0.6002", So to do some processing, in addition, the%ver_prefix% is stored in a similar "6.0.600", in order to compare the older version number uses.
Because batch processing cannot implement nested embedding functionality, for example I want to compare the 6.0.6000.16386 and%ver_prefix% from the folder, can not be implemented, just use code to generate Dafa to deal with, in the 18~24 line is to generate code, The code is called in 63 rows and 69 rows. The 26 line is responsible for transferring the control to the newly generated file for execution.
Since the WinSxS folder has special permissions, the Takeown command is used to set the current user as the owner, then change the folder permissions with cacls, and then move the folder to the Winsxs_del folder with the move instruction. If there is a situation where the program cannot be executed, please move it back manually.

***

. NET Framework solves DLL Hell problems: A description of the problem:

***

From the customer's point of view, the most common version number problem is what we call the DLL Hell problem. Simply put, DLL Hell refers to a series of problems that arise when multiple applications attempt to share a common component, such as a Dynamic Connection library (DLL) or a Component Object Model (COM) class. Most typically, an application will install a new version number of the shared component, which is not backwards compatible with the existing version number on the machine. Although the application you just installed is performing correctly, the application that originally relied on the previous version number to share the component may no longer work. In some cases, the cause of the problem is more unpredictable. For example, when users browse certain Web sites, they download a Microsoft ActiveX at the same time? Control. Assuming that the control is downloaded, it replaces the original control on the machine regardless of the version number. Assuming that the control is used by an application on the machine, it is very likely that it will also stop working.

In many cases, it takes a very long time for the user to discover that the application has stopped working. The result is often very difficult to remember when a machine change affects the application. Users may recall installing something a week ago, but there is no obvious correlation between the installation and the status you see right now. To make matters worse, today there are very few diagnostic tools that help users (or help their technical support staff) determine what is wrong.

The solution to these problems is that the version number information of the different components of the application is not logged or strengthened by the system. Also, the changes that the system makes to an application can affect all applications on the machine-it is not easy to build an application that is completely isolated from the changes today.

It is very difficult to establish a quarantine application because the current execution environment simply agrees to the installation of a separate version number component or application. This limitation means that the writer of the component must write their code backwards, or there is a risk of terminating an existing application when they install the new component. In fact, it is very difficult to write code that is always backwards compatible if possible. In. NET, the side by side concept is at the heart of the issue of version numbers. "Side by Side" is the ability to perform the same component of different version numbers at the same time on the same machine. Using components that support juxtaposition, programmers do not have to work hard to maintain strict backward compatibility, because different applications are free to use different version numbers of a shared component.

. NET Framework and DLL Hell issues: publishing and Installation

Installing applications today is a multi-step process. In general, installing an application contains copies of many software components to disk, and a series of descriptive descriptions of those components in the system.

The separation of the entries in the Register and the files on disk makes it very difficult to copy the application and uninstall them. Also, there is a very loose relationship between the many items required to describe a COM class completely in the register. These items often contain items that are federated classes, interfaces, type libraries, and DCOM app IDs, and do not involve items that are placed in the document extensions or component categories of the booklet. Always manually keep these items in sync.

Finally, it is necessary to activate any COM class for this booklet trail. This greatly complicates the process of publishing distributed applications, due to the need to make appropriate entries to each client machine.

One common problem today is that it is unrealistic to update an executing application. This is the biggest problem with Web applications, and the Web application must stop working and then restart to update the COM classes used by the application.

These problems are mainly caused by the description of components that are separated from the components themselves. In other words, the application is not self-descriptive and independent.

The above is required. NET Framework solves the DLL Hell problem with a simple descriptive narrative.

***

Slim down for the Windows 7 WinSxS directory, and be cautious.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.