This subject matter has been beaten up so much, one can only wonder if there is anything more to say on the subject… My advice is going to be a little different, though: basically, don’t do anything. Well, almost.
The number one thing to avoid is to download and run any 3rd-party utility that supposedly “optimizes” or “clean” stuff on your computer. Those tools don’t do anything useful at best (beyond what Windows already offers) and in the worst cases they may wreak havoc with your machine beyond all hopes of repair.
Some of these utilities gets warm recommendations from random (and anonymous) internet users presenting themselves as “experts” in tech and not-so-tech forums, but let me give you some insight from the other side of the fence: software I have written or helped write in the past two decades collectively runs on tens of millions of computers. FastPictureViewer alone is closing fast on its first million installs and I can tell you that almost every time a user reports an installation issue (such as inability to install, uninstall or upgrade something) the problem could be traced back to either overzealous “cleanups” that removed vital registry entries or files from the computer, or alterations to the default security on registry hives that sometimes removed all rights to the Administrators or even the SYSTEM account itself (supposedly to prevent malware installation), creating inextricable situations where no one has the rights to restore the proper access rights…
The issues caused by those utilities can be insidious: everything appears to work as before (remember: they don’t do anything useful) but a problem might crop up months later when a round of automatic updates fails to install properly, leaving the computer in a broken state, or a service pack needs to be installed. Those adventurous users playing with dangerous things such as beta service pack might find themselves in the uncomfortable situation where something that cannot be uninstalled prevents something else from getting installed, creating a deadlock whose only issue in to reinstall the system from scratch.
Of course, when this happens, the user always points his finger to the innocent software publisher (or operating system vendor) and never to the freebee that silently messed up the computer in the first place. In particular, never, ever run anything that pretend to speed up your computer by “cleaning” your registry. There are millions of values in the registry and the access time to a particular one is largely independent of the total number of keys and values. Removing a few hundred “unused” keys (or even thousands) is not going to have any impact whatsoever on your computer performance. Nothing, nada, rien, niet, niente, niets, zero - just don’t do it.
Okay, but now what?
Run Disk Cleanup
Clean temporary and cached files from time to time: Windows has a built-in Disk Cleanup utility that works just fine for that. Click the Start button and type Disk Cleanup in the search box (XP users can simply run cleanmgr). This utility takes care of temporary files left behind, empties the Recycle Bin and removes unused stuff without messing up with anything vital. Disk Cleanup can be started from the command line and can be scheduled to run automatically on Windows XP or later operating systems. The Disk Cleanup tool will clean the Windows Thumbnail Cache by default, which may or may not be desired. If you want to keep the cached thumbnails, just uncheck the “Thumbnails” option in the list of stuff to clean up.
Defragment Your Hard Disk Drives
The second (and last) thing that you need to do to keep your computer in shape is to defragment your drives regularly. Again, Windows has all it takes to perform this task, and recent versions of the operating system (Windows 7…) actually became very smart about defragmentation and fast bootup. To make a long story short, the operating system watches what you do (what gets loaded during the boot sequences, what program are started and how often) and optimizes all it can: it gets smarter as you use it by trying to predict what will be needed next (prefetch), and optimize disk file placements according to the load sequence during boot. Learn how to defragment your hard drives, then schedule disk defragmentation to run automatically (XP, Vista and Windows 7) and forget about it.
Advanced users can force a full profile-based boot sequence optimization using the xbootmgr program, part of the Windows Performance Analysis toolkit. While not recommended for normal users, the Windows Performance Toolkit (WPT) contains a utility that profile and trace the computer’s boot sequence and optimize file placement in consequence. Get the toolkit and run the following command:
xbootmgr -trace boot -prepSystem -verboseReadyBoot
…from an administrative command prompt (your computer may reboot up to 6 times for the tool to learn and discover the optimal settings, so this process will take some time).
There is not much to do, beyond scheduling Disk Cleanup and the Disk Defragmenter, to keep your computer in normal shape. Leave page file management to Windows (unless you really know what you are doing), uninstall applications that you don’t use to free up some space and opt for Microsoft Security Essentials if you have a choice: it’s lean and mean and does not bog down your computer as much as some other AVs, free and commercial alike.