Windows stores temporary files in several places -- both on a per-user and per-system basis. While these locations are documented, they're not always well understood, especially in terms of which kinds of temporary files are stored in which folders. It's important to know where Windows keeps these files -- and to what end -- since temporary files can be a security problem and a maintenance issue.
This directory is used for temporary files generated by applications like the Windows Startup Repair and boot loader. Most of the files written here are diagnostics generated by those programs, so you can generally remove them without any ill effects unless a program has locked it for use.
This directory stores temporary files generated by Windows itself. Most of what's stored here can be deleted as long as it's not locked for use.
%AppData%\Local\Temp and %AppData%\LocalLow\Temp
These two related directories are the other most crucial temporary data folders in the system.
%Appdata% is a variable, a generic way to refer to the path to folders that store application data for the user currently logged in. If you open an instance of Explorer and type %Appdata% into the address bar, you'll see it resolve to the full path for your AppData folder. In Windows Vista and Windows 7, this is typically something like C:\Users\<your username>\AppData. In XP, it's C:\Documents and Settings\<your username>\Application Data.
Local and LocalLow (and a third folder, Roaming, which isn't central to this discussion) were introduced in Vista to separate application data that does not roam with the user (Local) from data that does (Roaming). LocalLow stores data specific to programs running under low system integrity, such as Internet Explorer add-ons, which are run with reduced privileges as a security measure. (You can read more about the intended uses for these folders at the Microsoft Knowledge Base and at the Vista PC Guy blog.)
All three of these folders store application-specific data, but only Local and LocalLow typically have a "Temp" subfolder. As with the other folders, programs will habitually dump temporary data there and not always clean up after themselves. This results in a a growing mass of files that can affect performance and a potential security hazard on an unsecured system, since those temp files could contain personal data.
The first of these two problems is not hard to understand, but the second can be deceptive. For instance, on my own system, I have an automated backup process that runs once a day and makes differential backups of my Appdata folder (among other things) to a network repository. If there are many megabytes of junk in the Temp folder, they get backed up along with everything else, which slows down the backup process and eats into my backup space allotment. So keeping those directories clean -- and, if possible, away from prying eyes -- is worth the effort.
Because these temp files can pile up over time, and because many programs don't clean up after themselves (or in the case of programs that crash, they never get the chance to do so), it pays to take some extra measures.
1. Use the Disk Cleanup utility
In Windows Vista and Windows 7, you can run the Disk Cleanup utility from the Start menu. Type "Disk Cleanup" to bring it up, select "Temporary files" from the list of cleanup options that appears, and click OK.
2. Schedule a cleanup
Windows XP featured a way to directly schedule a disk cleanup operation. Unfortunately this option isn't around in later operating systems, but you can manually schedule a cleanup operation.
3. Delete the files manually
This is the least convenient option, but it's useful to know how to do it by hand. Browse to the appropriate temp folder in Explorer, select all, hit Delete, and click OK. Close all open applications before doing this, just to make sure none of the temp files there are being held open by programs you're running. Note that some files might still be in use by the system and will not be accessible. If you get a warning that a file cannot be deleted because it's in use, just select "Skip" and "Do this for all current items" to avoid further nag boxes.
ABOUT THE AUTHOR:
Serdar Yegulalp has been writing about personal computing and IT for over 15 years for a variety of publications, including (among others) Windows Magazine, InformationWeek and the TechTarget family of sites.