TEMP/TMP environment variable - DOS/Command Prompt Reference
Environment variable ‘TEMP’ and ‘TMP’ have the path name of the directory used as ‘temporary directory’ in MS-DOS and Windows. ‘Temporary directory’ is used for a place, when processing something, where to put a file containing such as temporary downloaded data or large data which cannot be kept in memory block.
In MS-DOS, the value of an environment variable ‘TEMP’ is used for a place of a temporary file created while executing pipe operation. Also, it is used for a temporary file place in Diskcopy. To speed up access to the temporary directory, TEMP can be a directory path in RAM drive (a volatile drive in memory which disappears on reboot) created by RAMDRIVE.SYS.
In Windows, the path returned by Windows API ‘GetTempPath’ will be the value of this environment variable. The value of ‘TMP’ is used first and, if the variable or the directory of its value does not exist, the value of ‘TEMP’ is used. Applications can use the temporary directory by using ‘TMP’ or ‘TEMP’ variable directly or by calling GetTempPath or GetTempFileName functions to retrieve paths.
* If both ‘TMP’ and ‘TEMP’ are invalid, the current directory is used in Windows 95/98/Me, and Window directory is used in Windows NT series (including XP or later).
set TEMP=X:\Work someapp.exe
Executes ‘someapp.exe’ with setting the temporary directory to ‘X:\Work’.