On both workstations and servers, Windows 2000 dedicates several directories to temporary files. One is for the system itself, in %SystemRoot%\Temp. The others are in the folder \Documents and Settings\<username>\Local Settings\Temp, where <username> is of course the user's name. One such TEMP directory exists for each user.
Many applications use these directories to deposit temporary files, as the name implies. The bad news is that not all of them clean up after themselves. After enough time and enough programs, the accumulation of junk files in the TEMP directories gets bad enough that many programs may begin to spontaneously fail.
This situation includes installer programs, which may be unable to unpack their contents into the TEMP directories for installation if there are other files with the same names there. If several different programs use the same installer technology with the same temporary file nomenclature, and the TEMP directories aren't cleaned up between each installation, things can get problematic if the installer refuses to overwrite what it thinks are its own files.
The best approach to this problem is regular hygiene: keep the TEMP directories empty. Because the system tends to lock many of the files in the TEMP directories while a user is logged in, the best approach involves a little side-stepping.
- Create a batch file to purge the contents of each TEMP directory. One way to do
- this is to use the RD /S command to completely remove the directory and all of its subdirectories, and then recreate it with MKDIR.
- Create a new user account that has Administrator permissions. For the ease of remembrance, call it purge. Do not assign it to more than one user group, as this may cause less-privileged user groups to override its Administrator privileges.
- Log out all other users, including the Administrator account, and log in as purge. Set up the batch file in the Startup folder so that it runs automatically when the login takes place. You can optionally add a logoff command at the end of the batch file so that the user is logged off when the cleanup operation is finished.
- Another option is to run the batch file as a scheduled job in the context of the purge user. This may create conflicts if other users are logged on at the time, so you may want to schedule it at an hour when it is unlikely that other users are logged on. (Note that this only covers users who are logged into the physical console or are connected via Terminal Services, not users who are accessing file shares.)
Serdar Yegulalp is the editor of the Windows 2000 Power Users Newsletter. Check out his Windows 2000 blog for his latest advice and musings on the world of Windows network administrators – please share your thoughts as well!
This was first published in July 2003