Windows "TEMP" Directory Cleanup
Disclaimer: If you do not understand the process below, then do not attempt it without the assistance of a PC professional who can grasp the concept. Although anyone can make it work correctly without special software, it can cause your system to lock up if done improperly. This information is offered without warranty or any promises. While I find it valuable and set it up on virtually every PC I work on, you use it at your own risk. If you have problems, I will attempt to help, but again I make no claim to be able to correct any mistake you might cause.
Background: Since at least version 3.0, Windows programs have created temporary files which serve no purpose once the programs are finished (exited). Early versions of Windows could place the files anywhere and they forever took up space on the hard drive. Later versions (Windows 95 & 98) at least placed them in a specific location, usually the "C:\Windows\Temp\" directory (now called a folder). If you open the Windows Explorer and locate the "C:\Windows\Temp\" directory you will probably find a few, if not hundreds, of files. Most of those files can be deleted, except for ones in use.
Microsoft Office programs, like Word, now also create temporary files in the directory where existing files are opened, but those are deleted automatically unless the program crashes. Temporary files normally end with the file extension ".tmp", however, they can have other extensions in the TEMP directory. Occasionally, temporary files have a "~" symbol as a prefix.
Beginning with Windows 95, some temporary files began showing up as "read-only", "hidden", or "system" files. Those files required special actions to delete and, in the case of hidden or system files, may not be visible. To complicate matters, some programs in Windows 95 & 98 also started creating sub-directories below the TEMP directory - those directories have to be manually deleted (unless you are running Windows NT or later).
While hard drive space is less critical than just a couple of years ago, it bothers me to know that I have wasted space on my hard drive. Being a PC old-timer who is comfortable working in DOS (The MS-DOS prompt) and with batch files, I use a simple technique that removes all temporary files from my TEMP directory each time I start my PC and before Windows can create new ones that cannot be removed until the next time I start the computer.
Technique for cleaning up the TEMP directory: Shared with me by Yucheng Song: (Win 98 and earlier) Locate and start the "Notepad" program found under Programs / Accessories on the Windows Taskbar. When Notepad has started, select, from the Notepad menu, File / Open. Locate the beginning folder for the C: drive - after you have selected it you should only see [C:] and an icon for the drive. from the pull down list for Files of Type, select "All Files *.*". Locate and click on the file named "Autoexec.bat", click the [Open] button. (alternately, you can select File / Open, type c:\autoexec.bat in the file name box, and press [Enter].) Move to the very last line, place your cursor after the last character in the line, and press the [Enter] key twice. Your cursor should now be on a blank line. Enter the following exactly as shown below - or highlight the contents of the box below, copy it (right mouse click and select Copy or highlight it and while holding down the [Ctrl] key, press the [Insert] key, and paste it to the new blank line. (See note at the bottom of this page)
Select File / Save from the menu. The line deletes all files in the C:\Windows\Temp directory AND deletes the files and directories below it. The C:\Windows\Temp directory will remain but without files or directories below it.
All files and subdirectories will now be deleted from the TEMP directory the next time you start your PC. To verify that it works properly, check the contents of the "C:\Windows\Temp\" directory, restart Windows, and check the directory again. None of those files or subdirectories present before restarting should be there afterwards.
Thank you Yucheng Song!
Windows NT 4/ WIN 2K / WIN XP: The technique for doing this for Windows NT, 2K, and XP is a little different. With those Operating Systems you also delete any sub-directories under TEMP automatically.
First, find the path to your TEMP directory (it may not be as the example below). Next, create a BAT file, any file name with the extension ".bat" such as clean.bat, using a text editor, like Notepad, with the following two lines (press [Enter] after the second line.
The first command "rd c:\windows\TEMP" =Remove Directory c:\windows\Temp. The /s parameter includes sub directories of c:\temp. The /q is the "quiet mode", which eliminates the need for you to make a response. The next command (md=Make Directory) recreates the Temp directory.
When the file has been saved, create a link in the StartUp folder (Start / Settings / Taskbar & Start Menu).
That's it! Next time you start up the PC the bat file will execute, delete the Temp folder and its sub folders, then, re-create the Temp folder.
Questions or comments?
NOTE: The universal Windows commands for
[Ctrl]+[Insert] = Copy
[Shift]+[Insert] = Paste
[Shift]+[Delete] = Cut
These combinations have been standards for Windows since version 3.0 or earlier. The introduction of [Ctrl]+C, [Ctrl]+V, & [Ctrl]+X were added to Windows programs to make Mac users feel more comfortable.
Back to TopBack to Free Stuff