
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 set | Default path | Used by |
|---|---|---|
| User TEMP / TMP | %USERPROFILE%\AppData\Local\Temp | Programs you run, installers, browsers |
| System TEMP / TMP | C:\Windows\Temp | Services 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.
Step 2: Open the Environment Variables window
- Press Win + R, type
sysdm.cpland press Enter. - 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.
Step 3: Edit TEMP and TMP
- In the top section (User variables for …), select
TEMPand click Edit. - Change the value to
D:\Tempand click OK. - Repeat for
TMP. - To change the system TEMP as well, do the same in the bottom section (System variables). This needs administrator rights.
- 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.
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
cleanmgrand 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.


