Why does %TEMP% resolve to a non-deterministic path of the form %TEMP\?

前端 未结 2 1832
抹茶落季
抹茶落季 2020-12-24 15:37

I have a Windows Server 2008 32 bit and when I\'m typing %temp% it takes me to ..AppData\\Local\\Temp\\1\\ or ..AppData\\Local\\Temp\\2 instead of ..AppData\\Local\\Temp

2条回答
  •  忘掉有多难
    2020-12-24 15:46

    Environment variables have 4 contexts:

    (do Win+R then type regedit to find the paths below)

    1. System variables (HKLM\System\CurrentControlSet\Control\Session Manager\Environment)
    2. User variables (HKCU\Environment)
    3. Process variables (not stored in the registry)
    4. Volatile variables (HKCU\VolatileEnvironment)

    ref: https://rakhesh.com/windows/temp-environment-variable-has-a-2-or-other-number-after-it/

    When the Group Policy Do not use temporary folders per session isn't configured or isn't set to Enabled, the system will generate two Volatile Environment variables TEMP & TMP with the same value of the current user's TEMP variable with the addition of an incremental number at the end of the TEMP folder (increments each time the user logs in, check @Damien's answer for details)

    If you set the group policy Do not use temporary folders per session to enabled, this behavior will not occur.

提交回复
热议问题