The enduring legacy of TMP and TEMP: How MS-DOS history shapes modern Windows file paths
From CP/M compatibility to the file piping features of MS-DOS 2.0, the coexistence of two environment variables remains a deliberate artifact of computing evolution.
A recent analysis published on the Microsoft Old New Thing blog in 2015 provides a definitive explanation for why modern Windows systems still maintain two distinct environment variables for temporary file locations: TMP and TEMP. The persistence of both variables is not a modern oversight but rather the result of specific historical design decisions made during the transition from the CP/M operating system to MS-DOS.
The roots of this duality lie in the early days of microcomputing in 1973, when the CP/M operating system launched without support for environment variables. In that era, configuring a program to specify a temporary file location required hard-coded settings or patching the executable itself, a practice the author recalls using with software like WordStar. When MS-DOS arrived in 1981, it was designed with strong compatibility goals for CP/M, meaning the first batch of applications were ports of CP/M software that ignored environment variables entirely.
As native MS-DOS applications began to emerge in the subsequent years, developers started adopting environment variables for configuration, leading to the emergence of TMP and TEMP as industry standards. The situation became more complex with the release of MS-DOS 2.0, which introduced the ability to pipe the output of one program as the input of another. This feature required the operating system to create temporary files to simulate the process, prompting the COMMAND.COM shell to select the TEMP variable specifically for this purpose.
This decision by COMMAND.COM created a divergence in the ecosystem, as other programs retained the use of TMP. While many applications attempted to appease both sides by checking for both variables, the priority order varied depending on the original author's preference. For instance, legacy utilities such as DISKCOPY and EDIT were known to check for TEMP before looking for TMP.
In the modern Windows era, the conflict persists but has been resolved in favour of one variable for system functions. The GetTempFileName function, used by contemporary Windows programs to create temporary files, prioritises the TMP variable over TEMP. Consequently, while the Environment Variables configuration dialog still displays both options, the directory used for temporary files is largely at the discretion of the specific program, with Windows applications likely to utilise TMP.
The article concludes by likening the situation to a rivalry between Adidas and Puma, noting that both variables continue to duke it out for attention in system configurations. This historical divergence ensures that while modern tools follow the TMP standard, legacy tools may still prefer TEMP, keeping both variables active in current system setups.
