Changing the temporary directory

1 January 2000 by Snakefoot | Comment » | Trackback Off
The temporary directory is specified by two environment variables called TMP and TEMP. When an application or batch file have to create an temporary file, then they can use one of these variables to get the path of the temporary directory.

To move the TEMP directory to another folder/partition/HDD edit the file AUTOEXEC.BAT and insert/update these lines (Best to place them in the top of the file):

REM *** Places all temporary files in the directory D:\TEMP ***
SET TEMP=D:\TEMP
SET TMP=D:\TEMP

Note the temporary directory is a location where files often are created and deleted. Some times it can be useful to move the temporary directory to another location.
  • The partition holding the temporary directory is low on free space.
  • File fragmentation introduced by the temporary directory is better placed on another partition.
  • There exist another partition which is much faster.
Note that many programs likes to create files in the TEMP directory, but few remembers to delete them again. Therefore it can be a good idea to clean the TEMP directory at bootup. This can be done by adding these lines to the AUTOEXEC.BAT (Below the lines that specifies TMP and TEMP):

ECHO Clearing TEMP directory : %TEMP%
DELTREE /Y %TEMP%\*.* >NUL

More Info MS KB Q130075

Updated: 2 July 2007

Leave a comment


You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>