TEMP vs TMP in Environment Variables

22

5

Is it right to have these two environment variables TEMP and TMP? If I make changes to one should I make the same changes to the other? For example I was installing cygwin and the directions told me to change the PATH variable, but both TEMP and TMP have the path variable. What is the difference between the two?

screen shot of environment variables

Not sure why people want to see this but here's the values to the path: Path in TEMP: C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Windows Live\Shared

Path in TMP: %USERPROFILE%\AppData\Local\Temp

Celeritas

Posted 2014-02-01T09:53:36.590

Reputation: 7 487

4

Check out the this article Why are there both TMP and TEMP environment variables, and which one is right? According to this, TMP might be the one to prefer (due to the GetTempFileName function)...

– aschipfl – 2016-09-08T14:32:46.697

Where is the Path variable in the temps I can't see it in your screen shot – user151019 – 2014-02-02T12:41:07.093

@Mark what does it matter? – Celeritas – 2014-02-02T20:19:37.343

@DavidMarshall what does it matter? – Celeritas – 2014-02-03T01:23:49.533

My question isn't how to change the path variable. And if it was your guys answers would be wrong because my point is, when changing any variable should it be done to TEMP, TMP or both. And you don't specify. – Celeritas – 2014-02-03T01:24:26.537

@DavidMarshall I meant it as an example to when a distinction may need to be made. They do to both have PATH. – Celeritas – 2014-02-03T21:49:26.670

@DavidMarshall I updated the question, did I understand what you wanted to see correctly? – Celeritas – 2014-02-03T21:52:54.230

@Mark CC above comment – Celeritas – 2014-02-03T21:53:10.887

@Celeritas why do we need the PATH variable which you mention in your question and it is not part of the value of TMP. The question is not what is PATH but why do you mention it at all – user151019 – 2014-02-04T00:16:14.693

@Celeritas we don't say specify as programs will use one or the other or use them for different reasons so it depends on which programs you use – user151019 – 2014-02-04T00:17:49.890

Answers

11

To answer the question specifically:

What is the difference between the two?

There is no difference. They are just different aliases for the same path. As Mark mentioned, some programs use %TMP% while other use %TEMP%. Windows assigns both to the same path by default to ensure consistency between different programs, and even protect against developer errors such as using both in the same program.

Also note that the %Path% variable has nothing to do with either %TMP% or %TEMP%. %Path% is a system variable, while %TMP% and %TEMP% are both system variables as well as user variables. The system versions link to C:\windows\TEMP. AFAIK, only the "System" user can actually use those variables, as evidenced by a simple test; open a cmd window and type in echo %TMP% or echo %TEMP%, and it returns the path defined in the user version of the variables. However since %Path% has no user version (by default), you can do echo %Path% and it returns the value of the system variable.

I'm not entirely sure how programs use the "Path" system variable, which is likely what cygwin was referring to, but regardless, I can assure you it has nothing to do with TMP or TEMP.

Hope that answers your question.

EDIT: I just remembered what %Path% is for — it lets you access any files that are in any of the paths specified in the variable without needing to use the full path to the file. For example, adding "C:\myprog\bin" to %Path% will let you just type myprog or myprog --help etc into the command-line without having to type out the full path, like "C:\myprog\bin\myprog.exe" --help. Of course command-line use is only an example, it lets any program or interface access any kind of file without needing the full path.

RyanayR

Posted 2014-02-01T09:53:36.590

Reputation: 149

Interesting. I cannot compress directories, because I got access denied sometimes. Changing the TEMP and TMP to %USERPROFILE%\AppData\Local\Temp fixed one of my problems, but generated many more. I changed it back to C:\Windows\Temp. If there is an user version, then the system can use C:\Windows\Temp, while I can use %USERPROFILE%\AppData\Local\Temp and everybody is happy. I'll give it a try. Thanks! – inf3rno – 2017-02-08T01:37:13.733

They are different some programs use one and some the other so you do need both – user151019 – 2014-02-02T12:40:28.373

3

You do need both as different programs use different ones.

They do not need to be set to the same place as only very badly written programs will use both assuming they point to the same thing.

/tmp is a common directory for temporary files in Unix also using the environment variable TMPDIR

From memory (when I used this in mid '80s) TEMP was the original one used in DOS and TMP tended to be used by programs that were ported from Unix to match the /tmp. However when programs got written in DOS as there was no control different developers used different ones. In modern Windows Microsoft's default is the same for both see this doc

user151019

Posted 2014-02-01T09:53:36.590

Reputation: 5 312

@J, SUS is ???? – Pacerier – 2017-07-29T11:27:39.670

1Bit late now but: Single UNIX Specification. – Tim Diggins – 2017-08-30T13:35:03.323

2

Actually, the standard SUS variable is TMPDIR. The standard has no mention of either TMP or TEMP, both of which originated in the DOS world.

– JdeBP – 2014-02-02T22:10:32.867