Environment variables not being set correctly

Snookred 31 Reputation points
2026-11-05T16:37:50.93+00:00

When setting up my Windows Systems I need to customize how the environment variables are set. In this case it is the ones used for locating where temporary files get stored (i.e., TEMP=, and TMP=). An image displaying how they are set in System Properties>Advanced follows:

User's image

Then an image showing how they are set in a command prompt follows:

User's image

When setting the System Properties the environment variable for user name (i.e., %USERNAME%) is used to specify the sub-folder in which files are actually stored. I normally run my computers using a Standard user, which means I also have another user, in this case named "Root", to be used when Administrator permissions are needed. Interestingly, these variables are set as expected when using the account named "Root".

It might also be worth pointing out that I have several Windows computers that I currently use regularly as well as lots of others that I've retired and this setup has always worked as expected, except in this one case.

Also, this is not a major problem since I am able to define a folder named "System" for storing said files. However, there is no user named "System" on any of my Windows computers.

Windows for home | Windows 10 | Settings
0 comments No comments

3 answers

Sort by: Most helpful
  1. Emma1-N 14,895 Reputation points Microsoft External Staff Moderator
    2026-11-06T01:22:12.5333333+00:00

    Hello Snookred,

    Since this is a public forum, we will hide your personal identifiable information, and I have sent that image of yours containing your personal identifiable information in a private message so we can work together to resolve the issue.

    Thanks for the detailed post and screenshots. Please note that Windows 10 reached end of support on October 14, 2025 (details). You can still try these steps.

    A value of "SYSTEM" usually means %USERNAME% was expanded under the SYSTEM account instead of your own, or something is overriding it. Two quick questions:

    • Is "TEMP" or "TMP" also defined under System variables?
    • Did you sign out and back in after making the change?

    Step 1: Check the stored values In a normal (non-admin) Command Prompt, run:

    reg query HKCU\Environment

    reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"

    Under Environment, "TEMP" and "TMP" should be REG_EXPAND_SZ. Any system-level entry that uses %USERNAME% will resolve to "SYSTEM".

    Step 2: Check for a Command Prompt AutoRun entry

    reg query "HKCU\Software\Microsoft\Command Processor" /v AutoRun

    reg query "HKLM\Software\Microsoft\Command Processor" /v AutoRun

    If either one returns a value, it might be changing TEMP/TMP. (cmd – AutoRun)

    Step 3: Re-create the variables

    • Go to "System Properties" > "Advanced" > "Environment Variables".
    • Delete "TEMP" and "TMP" under "User variables for David".
    • Add them again with the value T:\Temp\%USERNAME%.
    • Sign out, sign back in, and run set again.

    Please share what Steps 1 and 2 return so we can narrow this down.

    Looking forward to your update.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. Snookred 31 Reputation points
    2026-11-06T16:46:48.2966667+00:00

    By the way, I am aware the Windows 10 reached end of support. However, this computer is not able to run Windows 11 and it still works pretty good. It does occur to me that this problem may not be unique to Windows 10. Like I said, given my intentions it is not causing any serious problem.

    Regarding Step 3: Deleting, then recreating TEMP & TMP environment variables and then rebooting the computer did not result in any change of behavior regarding this matter.

    Was this answer helpful?

    0 comments No comments

  3. Snookred 31 Reputation points
    2026-11-06T16:31:51.87+00:00

    This is something that I've been doing on my Windows computers for decades now. It is part of the initial setup that I do which in this case was years ago. I do also change the values under System Variables but in that case I did not use any variable. I simply changed both to "T:\Temp\Windows". I've certainly signed out and back in many times since I did this but I don't remember when the next sign out was done in relation to the change.

    Regarding Step 1: I substituted "MyName" for the actual user name which you redacted.

    C:\Users\MyName>reg query HKCU\Environment

    HKEY_CURRENT_USER\Environment

    OneDrive    REG_EXPAND_SZ    C:\Users\MyName\OneDrive
    
    Path    REG_EXPAND_SZ    %USERPROFILE%\AppData\Local\Microsoft\WindowsApps;
    
    TEMP    REG_EXPAND_SZ    T:\Temp\%USERNAME%
    
    TMP    REG_EXPAND_SZ    T:\Temp\%USERNAME%
    
    OneDriveConsumer    REG_EXPAND_SZ    C:\Users\MyName\OneDrive
    

    C:\Users\MyName>reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

    ComSpec    REG_EXPAND_SZ    %SystemRoot%\system32\cmd.exe
    
    DriverData    REG_SZ    C:\Windows\System32\Drivers\DriverData
    
    IOLIBS    REG_SZ    T:\$MarsApps\darktable\lib\libgphoto2_port\0.12.2
    
    NUMBER_OF_PROCESSORS    REG_SZ    8
    
    OS    REG_SZ    Windows_NT
    
    Path    REG_EXPAND_SZ    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%SYSTEMROOT%\System32\OpenSSH\
    
    PATHEXT    REG_SZ    .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    
    PROCESSOR_ARCHITECTURE    REG_SZ    AMD64
    
    PROCESSOR_IDENTIFIER    REG_SZ    Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
    
    PROCESSOR_LEVEL    REG_SZ    6
    
    PROCESSOR_REVISION    REG_SZ    5e03
    
    PSModulePath    REG_EXPAND_SZ    %ProgramFiles%\WindowsPowerShell\Modules;%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules
    
    TEMP    REG_SZ    T:\Temp\Windows
    
    TMP    REG_SZ    T:\Temp\Windows
    
    USERNAME    REG_SZ    SYSTEM
    
    windir    REG_EXPAND_SZ    %SystemRoot%
    
    ZES_ENABLE_SYSMAN    REG_SZ    1
    

    Regarding Step 2:

    C:\Users\MyName>reg query "HKCU\Software\Microsoft\Command Processor" /v AutoRun

    ERROR: The system was unable to find the specified registry key or value.

    C:\Users\MyName>reg query "HKLM\Software\Microsoft\Command Processor" /v AutoRun

    ERROR: The system was unable to find the specified registry key or value.

    Regarding Step 3:

    In order to sign out and then back in I'll need to answer in a subsequent post.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.