This tutorial will show you how to delete user and system environment variables in Windows 10 and Windows 11.
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. The variables can be used both in scripts and on the command line. Environment variables makes it easy when certain standard directories and parameters need to be referenced but where the actual locations or names can vary from computer to computer.
The variable (ex: "%UserProfile%" for command and "$Env:UserProfile" for PowerShell) is used as a type of shortcut of the value (ex: "C:\Users\<username>").
There are two types of environment variables: user environment variables (set only for current user) and system (machine) environment variables (set for all users).
User environment variables are stored in the registry key below:
HKEY_CURRENT_USER\Environment
System environment variables are stored in the registry key below:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
You can open a command prompt, type set
, and press Enter to display all current environment variables on your PC.
You can open PowerShell, type Get-ChildItem Env:
, and press Enter to display all current environment variables on your PC.
- Option One: Delete User Environment Variables in Environment Variables
- Option Two: Delete User Environment Variables in PowerShell
- Option Three: Delete User Environment Variables in Registry Editor
- Option Four: Delete System Environment Variables in Environment Variables
- Option Five: Delete System Environment Variables in PowerShell
- Option Six: Delete System Environment Variables in Registry Editor
1 Open the Control Panel (icons view), and click/tap on the User Accounts icon.
2 Click/tap on the Change my environment variables link on the left side, and close the User Accounts control panel window if you like. (see screenshot below)
This opens rundll32.exe sysdm.cpl,EditEnvironmentVariables
.
3 Under the top User variables for <current user name> section, select the variable (ex: "Downloads") you want to remove, and click/tap on Delete. (see screenshot below)
4 When finished deleting user variables for your account, click/tap on OK to apply. (see screenshot below)
1 Open Windows Terminal, and select Windows PowerShell.
2 Type the command below into Windows Terminal, and press Enter. (see screenshot below)
[Environment]::SetEnvironmentVariable("[variable name]",$null,"User")
Substitute [variable name] in the command above with the actual variable name (ex: "Downloads") you want to delete.
For example: [Environment]::SetEnvironmentVariable("Downloads",$null,"User")
3 You can now close Windows Terminal if you like.
1 Open Registry Editor (regedit.exe).
2 Navigate to the key below in the left pane of Registry Editor. (see screenshot below step 3)
3 In the right pane of the Environment key in Registry Editor, right click or press and hold on the value name (ex: "Downloads") of the variable you want to delete for your account, and click/tap on Delete. (see screenshot below)
4 Click/tap on Yes to confirm. (see screenshot below)
5 When finished deleting user variables for your account, you can close Registry Editor if you like.
You must be signed in as an administrator to use this option
1 Open Advanced System Properties (SystemPropertiesAdvanced.exe).
2 Click/tap on the Environment Variables button. (see screenshot below)
3 Under the bottom System variables section, select the variable (ex: "Downloads") you want to remove, and click/tap on Delete. (see screenshot below)
4 When finished deleting user variables for your account, click/tap on OK to apply. (see screenshot below)
5 Click/tap on OK. (see screenshot below)
You must be signed in as an administrator to use this option
1 Open Windows Terminal (Admin), and select Windows PowerShell.
2 Type the command below into Windows Terminal (Admin), and press Enter. (see screenshot below)
[Environment]::SetEnvironmentVariable("[variable name]",$null,"Machine")
Substitute [variable name] in the command above with the actual variable name (ex: "Downloads") you want to delete.
For example: [Environment]::SetEnvironmentVariable("Downloads",$null,"Machine")
3 You can now close Windows Terminal (Admin) if you like.
1 Open Registry Editor (regedit.exe).
2 Navigate to the key below in the left pane of Registry Editor. (see screenshot below step 3)
3 In the right pane of the Environment key in Registry Editor, right click or press and hold on the value name (ex: "Downloads") of the variable you want to delete for your account, and click/tap on Delete. (see screenshot below)
4 Click/tap on Yes to confirm. (see screenshot below)
5 When finished deleting system variables, you can close Registry Editor if you like.
That's it,
Shawn Brink