Why does the system convert TEMP to a short file name?

Raymond Chen

When you set environment variables with the System control panel, the TEMP and TMP variables are silently converted to their short file name equivalents (if possible). Why is that?

For compatibility, of course.

It is very common for batch files to assume that the paths referred to by the %TEMP% and %TMP% environment variables do not contain any embedded spaces. (Other programs may also make this assumption, but batch files are the most common place where you run into this problem.)

I say “if possible” because you can disable short name generation, in which case there is no short name equivalent, and the path remains in its original long form.

If you are crazy enough to set this value and point your TEMP/TMP variables at a directory whose name contains spaces and doesn’t have a short name, then you get to see what sorts of things stop working properly. Don’t say I didn’t warn you.

0 comments

Discussion is closed.

Feedback usabilla icon