windows Vista 环境变量中的 %TMP% 和 %TEMP% 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/581966/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's the difference between %TMP% and %TEMP% in Vista environment variables?
提问by Brann
On my computer, the environment variables %TMP% and %TEMP% both point to the same location.
在我的电脑上,环境变量 %TMP% 和 %TEMP% 都指向同一个位置。
Are those for backward compatibility issues only, or is there a real difference?
那些只是为了向后兼容问题,还是有真正的区别?
采纳答案by TorgoGuy
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.
是为了兼容性。它一直回到DOS。由于没有标准,一些 DOS(和 Win 3.x)应用程序会查找 %TMP% 环境变量,而其他应用程序会查找 %TEMP%。如果您在 AUTOEXEC.BAT 文件中同时设置它们,您就最好了。
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.
Windows NT 会自动设置它们,以确保所有应用程序继续正常工作。%TEMP% 现在是标准,但 %TMP% 仍然存在。
EDIT: Looks like Richard already mentioned the DOS aspect in a comment.
编辑:看起来理查德已经在评论中提到了 DOS 方面。
回答by VonC
回答by abatishchev
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\
我认为只是为了兼容性,正如我在 Windows 中看到的那样,从 NT 4.0 开始,这两个变量都针对 %WinDir%\Temp\
Also I never saw using %TMP%
, every time it was talking about %TEMP%
.
我也从来没有见过使用%TMP%
,每次都在谈论%TEMP%
。
回答by mwfearnley
Raymond Chentalks about the historical use of TMP
and TEMP
, and says this specifically about Windows:
Raymond Chen谈到了 和 的历史使用,TMP
并TEMP
特别谈到了 Windows:
For whatever reason, the original authors of the Get-Temp-File-Namefunction chose to look for
TMP
before looking forTEMP
.
无论出于何种原因,Get-Temp-File-Name函数的原始作者都选择先查找
TMP
再查找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.
本文的其余部分值得一读,以解释两者在 DOS 中的历史用途。听起来TEMP
半官方更喜欢 DOS ,而不是TMP
,但第三方程序员可以自由使用他们喜欢的东西,特别是考虑到 Windows 缺乏标准的 API 函数。