Changing the temporary directory

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 ***

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%

More Info MS KB130075