Recently my Windows Vista partition ran out of disk space. Well, the partition has 30GiB but that is not enough even if you choose to install 3rd party software on a separate disk. The main reason why Windows Vista needs so much space is the WinSxS folder which contains a lot of DLL files and more (at least for me). I don’t want to go into detail here but this folder holds (nearly) duplicate files for compability and language reasons.

Astonishment

However, I was (a little) astounded when I found out that in this folder also Windows Media (.WMV) files reside which took about 600MiB alone on my PC (depends on your situation and software). I watched them and can tell you that I’ve never seen them before and I won’t watch them in future. These files usually can be found in C\Windows\Help\Windows\<languageID>.  I have them in two language versions because it happens that I have installed a German and English language Windows pack.  Windows fools you by linking these files to any of the WinSxS file “duplicates”. Depending on your language  you always watch them in your language.

Command and Conquer your System

Removing these files is very trick. The reason is that the WinSxS folder is heavily secured against messing around. Only the user “Trusted Installer” () can get full control and it is also the owner. Well, that is nice for beginners. But experts – like me – want full control of their files. So the easiest way to get full access is to become the owner of each folder we want to remove. Then we can give us full control by adding our user to the access control list (ACL). However in this way we need a lot of time to change all these folders. We could also change the top folder and let the security changes iterate through the childs (folders and files). But this approach takes a long time and is also a security risk because all folders and files are changed without exceptions. You could also write a batch or any other script file to do the job, but I am not experienced enough for this.
Another problem is that we maybe want to keep a backup that can be restored in the case of an emergency (“I want to see these movies!”).

So which language could we use to become owner of a file, change file security, copy a file and more? Well, if you don’t  think Delphi you can stop reading now ;-)

TakeControl

I have created this application which I call “TakeControl”. It is a simple application that helps you to find files and let you access them with full control.
Its main task is to move files which you think aren’t necessary to have on the partiton.  In my case there were a lot of media files which I didn’t want to have (also in Windows folder).

The application dialog looks like this

takecontrol

The numbers in the picture are explained here:

1. This edit box receives a semicolon separated list of file extentsions (with a dot in front of each). It usually looks like “.mpg;.wmv”. Imo you should not add “DLL” or “MUI” file extensions there.

2. & 3. These edit boxes receive the source (2.) and target (3.) folders. The source folder defines where to search for the files and the target folder defines where to copy/move them. The source folder structure is retained in the target folder. So if a file is stored in this source folder : “C:\Windows” (2.)” say “\XXXX\File.wmv” and your target folder looks like “E:\temp” (3.) the new file will be created here: “E:\Temp\XXXX\File.wmv”.

4. If this checkbox is checked all files are copied instead of moved. Furthermore the security of the files aren’t changed at all. So if a file isn’t accessible an error is shown in the log memo (8.).
This checkbox is only available if you run with administrator privileges; otherwise you aren’t able to move files.

5.  This checkbox lets you do a simple search. No file is changed or copied/moved. In this way you can find out how many files there are and if there is a file which isn’t accessible at all.

6. The run button starts the process (with a confirmation prompt). If the search is in progress, you can abort it here.

7. The status area shows some (rare) information.
a) A waiting gradient shows you that something is still going on.
b) A status label shows you the current file processed.
c) A progress bar shows you the current copy/move operation progress.
d) Number of errors and already processed files are shown on the right side of the dialog.

Mandatory Instruction

Well, before you start, you should always backup your system (this is mandatory). In the next step you can try to get rid of the media files if you want. But do it at your own risk.

Appendix

Yes, I know, there are many other possibilities that can be used to clean the Windows partition. Trust me, I tried them all! The last step would be to buy a new hard disk. :twisted:

Sourcecode

Source code is available in the example folder of our Subversion repository only.  See Subversion description here.
Direct Subversion (for Checkout) and browser link is here.

Download history

TakeControl Version 0.7 (zipped ~700Kib)

Be aware that you run this program at your own risk

FAQ

Q:  I can’t move files because the checkbox isn’t enabled.
A: You need to run the application as a member of the Administrators group.

Q: I can do the same thing using X.
A: If X doesn’t include JWSCL or JWA it is not a subject for this blog. You are welcome to post a comment though.