What's the difference between %TMP% and %TEMP% in Vista environment variables?

后端 未结 4 1589
北海茫月
北海茫月 2021-01-01 12:17

On my computer, the environment variables %TMP% and %TEMP% both point to the same location.

Are those for backward compatibility issues only, or is there a real dif

相关标签:
4条回答
  • 2021-01-01 12:49

    Raymond Chen talks about the historical use of TMP and TEMP, and says this specifically about Windows:

    For whatever reason, the original authors of the Get­Temp­File­Name function chose to look for TMP before looking for TEMP.

    The rest of the article is worth a read in explaining the historical use of both in DOS. It sounds like DOS preferred TEMP semi-officially, rather than TMP, but third-party programmers were free to use what they liked, particularly given the lack of the standard API functions that Windows has.

    0 讨论(0)
  • 2021-01-01 12:53

    To complete the other answers:

    Environment variable

    in MS-DOS 5 (1991-1994) %TEMP% sometimes pointed to C:\DOS so removing all files in %TEMP% would cause great problems to say the least.

    http://www.operating-system.org/betriebssystem/bsgfx/microsoft/msdos500-scr-01.png

    0 讨论(0)
  • 2021-01-01 13:06

    It is for compatibility. It goes all the way back to DOS. Since there were no standards, some DOS (and Win 3.x) applications would look for the %TMP% environment variable and others would look for %TEMP%. You were best off if you set both of them in the AUTOEXEC.BAT file.

    Windows NT set both of them automatically just to make sure all of the apps continued to work OK. %TEMP% is the standard now, but %TMP% lives on.

    EDIT: Looks like Richard already mentioned the DOS aspect in a comment.

    0 讨论(0)
  • 2021-01-01 13:07

    I think only for compatibility, as I could see in Windows starting from NT 4.0 both variables were targeted to the same location in %WinDir%\Temp\

    Also I never saw using %TMP%, every time it was talking about %TEMP%.

    0 讨论(0)
提交回复
热议问题