Since 2016 · 50,000+ customers · ★ 5.0 on Google Live chatWhatsAppTelegramOpen a ticket
Get started
Windows Server

How to Change the TEMP Folder Location in Windows

How to change the TEMP folder location in Windows by 99RDP

Windows and most programs write temporary files to a TEMP folder on the C: drive. On a server or VPS with a small system disk, that folder can fill up and stop installs, updates and apps from working. Moving TEMP to another drive, such as a larger data disk or a fast SSD, takes a few minutes. This guide shows how to change the user and system temporary paths with the GUI, the command line and PowerShell, plus the permissions and Remote Desktop details that trip people up.

Quick answer

mkdir D:\Temp
setx TEMP D:\Temp
setx TMP D:\Temp

Sign out and back in for the change to take effect.

The two kinds of TEMP folder

Variable setDefault pathUsed by
User TEMP / TMP%USERPROFILE%\AppData\Local\TempPrograms you run, installers, browsers
System TEMP / TMPC:\Windows\TempServices and processes running as SYSTEM, Windows Update

Both TEMP and TMP exist for historical reasons; different programs read different ones, so always change both to the same path.

See the current values with:

echo %TEMP%
echo %TMP%

Step 1: Create the new folder

Create the folder first, for example D:\Temp. Windows won't create it for you, and a missing TEMP folder makes installers fail with confusing errors.

Steps to change the TEMP folder in Windows: open System Properties, Environment Variables, edit TEMP and TMP, sign out
Change TEMP in four steps

Step 2: Open the Environment Variables window

  1. Press Win + R, type sysdm.cpl and press Enter.
  2. Open the Advanced tab and click Environment Variables….

Shortcut: search the Start menu for "Edit environment variables for your account" to go straight to the user variables.

Comparison of user and system TEMP variables in Windows
User or system TEMP?

Step 3: Edit TEMP and TMP

  1. In the top section (User variables for …), select TEMP and click Edit.
  2. Change the value to D:\Temp and click OK.
  3. Repeat for TMP.
  4. To change the system TEMP as well, do the same in the bottom section (System variables). This needs administrator rights.
  5. Click OK to close both windows.

Step 4: Apply the change

Running programs keep the old path. Sign out and back in for user variables; restart the computer after changing system variables so services pick up the new path. Check the result with echo %TEMP% in a new Command Prompt.

PowerShell SetEnvironmentVariable scopes for TEMP: Process, User and Machine
PowerShell scopes

Change TEMP with PowerShell

# current user
[Environment]::SetEnvironmentVariable("TEMP", "D:\Temp", "User")
[Environment]::SetEnvironmentVariable("TMP",  "D:\Temp", "User")

# system-wide (run PowerShell as administrator)
New-Item -ItemType Directory -Force -Path "D:\SysTemp" | Out-Null
[Environment]::SetEnvironmentVariable("TEMP", "D:\SysTemp", "Machine")
[Environment]::SetEnvironmentVariable("TMP",  "D:\SysTemp", "Machine")

With Command Prompt, setx /M TEMP D:\SysTemp sets the system variable. Note that setx doesn't change the current window, only new ones.

Set the right permissions on a system TEMP folder

A new folder on D: inherits that drive's permissions, which may let every user read everyone else's temporary files, or may not let users write at all. For a shared system TEMP folder, use permissions similar to C:\Windows\Temp:

icacls D:\SysTemp /inheritance:r
icacls D:\SysTemp /grant "SYSTEM:(OI)(CI)F" "Administrators:(OI)(CI)F" "CREATOR OWNER:(OI)(CI)(IO)F"
icacls D:\SysTemp /grant "Users:(CI)(WD,AD,X,RA)"

That lets users create their own files and folders without reading other users' files. For user TEMP folders, keep one folder per user (for example D:\Temp\%USERNAME%) rather than a shared one.

On a Remote Desktop server

On Windows Server with Remote Desktop Services, Windows creates a separate subfolder per session inside the user's TEMP (for example ...\Temp\2) and deletes it at sign-out. That's controlled by Group Policy under Computer Configuration → Administrative Templates → Windows Components → Remote Desktop Services → Remote Desktop Session Host → Temporary folders. Leave the defaults on in most cases; they keep sessions separate and clean up automatically.

Clean up temporary files regularly

  • Storage Sense (Settings → System → Storage) can delete temporary files automatically on Windows 10/11 and Server 2022+ with Desktop Experience.
  • Disk Cleanup: run cleanmgr and tick Temporary files.
  • Manually: close programs, then delete the contents of %TEMP%; files in use are skipped.

Frequently asked questions

How do I change the temp folder location in Windows?

Create the new folder, then edit the TEMP and TMP environment variables in System Properties → Advanced → Environment Variables, and sign out and back in.

What is the difference between TEMP and TMP?

Nothing practical; both point to the temporary folder and different programs read different ones. Set both to the same path.

Is it safe to move the TEMP folder to another drive?

Yes, as long as the folder exists, has the right permissions and the drive is always present at startup.

Where is the Windows temp folder?

For your user, %USERPROFILE%\AppData\Local\Temp; for the system, C:\Windows\Temp. Type %TEMP% in the Run dialog to open yours.

Minakshi, Server Administrator L1 at 99RDP
Written byMinakshiServer Administrator L1, 99RDP. Part of the team that runs our servers and answers support.
Keep reading

More Windows Server guides

All Windows Server guides

Need a server for this?

✓ Setup in minutes✓ Full admin access✓ 7-day refund on new services