TEMP & TMP Values - Batch or Reg File to Change ?


wpr

New member
Local time
5:56 PM
Posts
20
Location
Florida
OS
Windows 11 23H2 22631.4460
I use a RAM disk for temporary files but when I have a large Windows update I need to change the Environment Variables' temp locations to a different disk. I do this manually each time for the four items (User: TEMP and TMP, System: TEMP and TMP). Does anyone have a batch or reg file that will do these changes? Also, do I need to change both the User and System locations when I do this, or just the User locations? Or, if you could tell me which registry items to modify I could probably create the file. Thanks for any info.
 
Last edited:

My Computer

System One

  • OS
    Windows 11 23H2 22631.4460
    Computer type
    PC/Desktop
    CPU
    AMD
    Motherboard
    ASRock
Could you not search the registry for the present values so you know where they are stored and modify to suit?
 

My Computer

System One

  • OS
    WIN 11 Pro 24H2 - 26100.2894
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom
    CPU
    Intel XEON E5-2699 v3
    Motherboard
    ASUS X99-A
    Memory
    48G Teamgroup UD4-3600
    Graphics Card(s)
    NVIDIA GeForce GTX 1080 Ti
    Sound Card
    Integrated
    Monitor(s) Displays
    ACER X34 Predator
    Screen Resolution
    3440 x 1440
    Hard Drives
    Crucial CT1000P 3P SSD8 1TB
    PSU
    GameMax Pro
    Case
    Fractal Design
    Cooling
    Corsair H110iGT + 6 140mm Fans
    Keyboard
    Corsair K4
    Mouse
    G-Skill G502
    Internet Speed
    50MBs
    Browser
    Chrome
    Antivirus
    OEM
I used this before 11 started to give temp errors, but I think you need to restart 11, restarting explorer might not be enough.
Code:
reg add "HKCU\Environment" /v "TEMP" /t REG_EXPAND_SZ /d "Z:\TEMP" /f
reg add "HKCU\Environment" /v "TMP" /t REG_SZ /d "Z:\TEMP" /f
taskkill /im explorer.exe /f & explorer.exe
 

My Computer

System One

  • OS
    Windows 11 Home
    Computer type
    PC/Desktop
    CPU
    AMD Ryzen 5 8600G (07/24)
    Motherboard
    ASROCK B650M-HDV/M.2 3.15 (07/24)
    Memory
    2x32GB Kingston FURY DDR5 5600 MHz CL36 @4800 CL40 (07/24)
    Graphics Card(s)
    ASROCK Radeon RX 6600 Challenger D 8G @60FPS (08/24)
    Sound Card
    Creative Sound BlasterX AE-5 Plus (05/24)
    Monitor(s) Displays
    24" Philips 24M1N3200ZS/00 (05/24)
    Screen Resolution
    1920×1080@165Hz via DP1.4
    Hard Drives
    Kingston KC3000 NVMe 2TB (05/24)
    ADATA XPG GAMMIX S11 Pro 512GB (07/19)
    PSU
    Seasonic Core GM 550 Gold (04/24)
    Case
    Fractal Design Define 7 Mini with 3x Noctua NF-P14s/12@555rpm (04/24)
    Cooling
    Noctua NH-U12S with Noctua NF-P12 (04/24)
    Keyboard
    HP Pavilion Wired Keyboard 300 (07/24) + Rabalux 76017 Parker (01/24)
    Mouse
    Logitech M330 Silent Plus (04/23)
    Internet Speed
    500/100 Mbps via RouterOS (05/21) & TCP Optimizer
    Browser
    Edge & Brave for YouTube & LibreWolf for FB
    Antivirus
    NextDNS
    Other Info
    Backup: Hasleo Backup Suite (PreOS)
    Headphones: Sennheiser RS170 (09/10)
    Phone: Samsung Galaxy Xcover 7 (02/24)
    Chair: Huzaro Force 4.4 Grey Mesh (05/24)
    Notifier: Xiaomi Mi Band 9 Milanese (10/24)
    2nd Monitor: AOC G2460VQ6 @75Hz (02/19)
I used this before 11 started to give temp errors, but I think you need to restart 11, restarting explorer might not be enough.
Yes, you need to restart the system as those are ENV variables that need to get initialized very early on.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    Laptop
    Manufacturer/Model
    ASUSTeK COMPUTER INC. TUF Gaming FX705GM
    CPU
    2.20 gigahertz Intel i7-8750H Hyper-threaded 12 cores
    Motherboard
    ASUSTeK COMPUTER INC. FX705GM 1.0
    Memory
    24428 Megabytes
    Graphics Card(s)
    Intel(R) UHD Graphics 630 / NVIDIA GeForce GTX 1060
    Sound Card
    Intel(R) Display Audio / Realtek(R) Audio
    Monitor(s) Displays
    Integrated Monitor (17.3"vis)
    Screen Resolution
    FHD 1920X1080 16:9
    Hard Drives
    2 SSD SATA/NVM Express 1.3
    WDS500G2B0A-00SM50 500.1 GB
    WDCSDAPNUW-1002 256 GB
    PSU
    19V DC 6.32 A 120 W
    Cooling
    Dual Fans
    Mouse
    MS Bluetooth
    Internet Speed
    Fiber 1GB Cox -us & 400MB Orange-fr
    Browser
    Edge Canary- Firefox Nightly-Chrome Dev
    Antivirus
    Windows Defender
    Other Info
    VMs of Windows 11 stable/Beta/Dev/Canary
    VM of XeroLinux- Arch based & Debian 12
  • Operating System
    Windows 11 Insider Canary
    Computer type
    Laptop
    Manufacturer/Model
    ASUS X751BP
    CPU
    AMD Dual Core A6-9220
    Motherboard
    ASUS
    Memory
    8 GB
    Graphics card(s)
    AMD Radeon R5 M420
    Sound Card
    Realtek
    Monitor(s) Displays
    17.3
    Screen Resolution
    1600X900 16:9
    Hard Drives
    1TB 5400RPM
There is no need to use the reg command for this purpose (even though you always could).

For the current user:
Code:
setx TMP Z:\Temp
setx TEMP Z:\Temp

System-wide:
Code:
setx /m TMP Z:\Temp
setx /m TEMP Z:\Temp

Some applications may not pick up the new values until they are restarted or until you log off and then log on again.
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
Thank you for your replies.

To hdmi: I put your codes (with the folder locations changed) into a bat file and ran it as administrator, then restarted my PC. The locations did not change in the Environment Variables box.

To TairikuOkami: Why does one line have REG_EXPAND_SZ and the other REG_SZ?

In my registry search for environment variables, I found five instances, each having both the TEMP and TMP names:
[HKEY_CURRENT_USER\Environment]
[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
[HKEY_USERS\S-1-5-21-1705685031-1339510746-3272408279-1001\Environment]

I use a 10GB RAM disk (Y) for general usage, but a large Windows update requires more space, which is why I change the locations. I have been changing all four values (user and system, temp and tmp) using the Environment Variables box. When doing this, do I need to change both the user and system temp file locations?
 

My Computer

System One

  • OS
    Windows 11 23H2 22631.4460
    Computer type
    PC/Desktop
    CPU
    AMD
    Motherboard
    ASRock
Windows update won't be using your profile, so there's no point in changing the user variables. The default for the system of C:\Windows\temp is traditional but not necessarily a good idea. That folder is user writeable, but not easily readable. There's probably merit in the suggestion in The 10 Commandments for Windows™ 10 (plus an 11th for Windows™ 11) (towards the end of #2) "Separate the system’s user-writable (shared) "TEMP" directory". I think that there are probably some applications hard coded to use C:\Windows\temp, which may be why it's not been fixed.

So don't change the user variable, and leave the system one pointing at a regular drive.
 

My Computer

System One

  • OS
    Windows 11 23H2 Pro
    Computer type
    PC/Desktop
    Manufacturer/Model
    MSI
    CPU
    i3-1215U
    Memory
    8GB
    Monitor(s) Displays
    Dell S2721
    Screen Resolution
    3840x2160
    PSU
    External 65W
    Keyboard
    Cherry mechanical (Blue)
    Mouse
    Microsoft
    Browser
    FireFox
    Antivirus
    MS

Latest Support Threads

Back
Top Bottom