Why does %TEMP% resolve to a non-deterministic path of the form %TEMP\<digit>?
Explanation, discussion, workarounds, etc, all under the Old New Thing article Why does the name of my TEMP directory keep changing - it ensures multiple terminal services sessions for the same user don't (by default) share a temp directory.
The problem lay in the Administrative Templates\Windows Components\Terminal Services\Temporary folders group policy. If you don't select Do not use temporary folders per session, then these TEMP subdirectories are created. There is also a knowledge base article describing the registry keys behind these group policies.
Personally, I find the first comment in reply to be the most useful:
Why does it matter if the temp location jumps around anyway, it's temporary!
See also
- Use separate temporary folders for each session