Some tips for reclaiming disk space on Windows

Introduction

One of the troubles with modern desktop operating systems and applications is that they typically contain a large number of files, too many to keep track of. In addition, in recent years the rise in use of automatic updates has increased the disk usage on many machines. In many cases this is not a problem, since disk are big enough to handle the load, but if (or when!) disk space becomes a problem it can be very hard to know where to start with freeing up spare capacity.

In general it is safest to leave files alone, but when you run out of disk space this can be a bigger problem than the risks taken by deleting some files. This is more frequently an issue on a laptop than on a dekstop machine as laptop disks tend to be smaller.

Many files can be managed easily by their creator but it is harder to deal with files that are created by the system. No-one wants to make the same mistake as the user who deleted the C:\WINDOWS directory on the grounds that it was using too much space....

Here are some of the ways I have used to reclaim disk space under Microsoft Windows.

Health Warning

Note on disk space reclamation

Deleting files can render your machine unusable. Good safety precautions include:

Temporary directories

Most machines have several temporary directories, typically including:

These directories tend to accumulate cruft but, as the name suggests, they are intended for temporary files. Periodically deleting the contents of these directories can reclaim diskspace.

Proviso: sometimes users keep important files in temporary directories, so be careful. I don't *know* of any applications that do.

Log files

Many programs write log files for installation or status. Sadly fewer programs manage these log files adequately, wich can result in large amounts of disk space being wasted.

Proviso: Deleting log files can obviously make problem determination difficult.

Failed updates

Some versions of Windows Installer have a bug that results in files that fail to install not being tidied up properly. Download the "Windows Installer CleanUp Utility" from http://support.microsoft.com/kb/290301 and execute the command "MSIZAP G!" as administrator to delete any orphaned installations.

I have retrieved as much as 8Gb of disk space from some machines using this program.

Proviso: I have never had a problem using the "G!" option with MsiZap, but some of the other options are highly dangerous!

Service packs

When service packs ("bug fixes") are installed either manually or via Microsoft Update the installer creates a backup directory in %windir% - for example $NtUninstallKB936782$

some of these directories can be quite large, and are only used if you decide to roll back the service pack. I have needed to do this several times - for example Windows Server 2003 SP1 turned one machine into a stone, and XP Home SP1 caused another to run at 10% of its advertised CPU speed.

However after a couple of months I am usually confident that there will be no need to revert to the old version, and so I periodically remove the old uninstall directories.

Windows Update

Downloaded files from the Windows Update process are stored in %windir%\SoftwareDistribution. This directory sometimes accumulates a lot of files, and can be purged. Note that if you purge the directory and then run Windows Update it will lose its history of what updates you have installed. However it will not attempt to re-apply already applied fixes.

Clearing this directory is one of the thing Microsoft Support recommend if the automatic updates service is not working, so it has some official approval.

Old versions of programs

Some programs overwrite the old version when a new version is installed, some programs do not. For example, when the Java runtime downloads a new version it leaves the old version installed. This is necessary in some cases - you might have a program that requires a specific version of the runtime - but in most cases the 'Add and Remove Programs' tool can be used to delete all but the most recent version.

Proviso: some uninstallation programs are flawed and uninstalling an old version can break a newer one. Make sure you still have the means of making a fresh installation as a failsafe.

Symbol files

If you make use of the Microsoft Symbol Server for your debugging you can collect a large amount of symbolic information in the local symbol cache. Old files - or even the entire cache - can be cleaned out, particularly if you have updated to a new version or service pack level of Windows.

The symbol cache is usually configured using the environment variable _NT_SYMBOL_PATH (although some tools use their own setting). On my laptop this variable is set to "SRV*C:\Symbols*http://msdl.microsoft.com/download/symbols", and I purge C:\Symbols when I am getting low on disk space.


Copyright (c) Roger Orr - rogero@howzatt.demon.co.uk