How to Clear Environment Variables in Windows

Environment variables may be helpful to programmers, system administrators, and other advanced users. They provide us with details about the environment wherein an application is running. In some instances, you can delete an environment variable. In other cases, you can change only its value.

How to Clear Environment Variables in Windows

Sometimes you might need to clear the environment variable on your Windows. But how can you do this? Keep reading to find out all the methods you can use to remove and change environment variables.

How to Unset Env Variable in Windows

The operating system’s environment makes use of data stored in environment variables. There is a lot of information we can learn from them about how the software works. Environment variables can be divided into two categories:

  • When a program is installed, the OS or driver sets these environment variables, which include information about system resources. These are called System Environment Variables. For instance, the windir variable will hold the location of Windows.
  • Information specific to a given user account is stored in User Environment Variables. Setting the PATH variable in order for the commands to run without having to provide the file path every time is an example of this.

There are ways to unset both types of Env Variables. You can do so by using the Environment Variables window, Power Shell, and Registry Editor.

Environment Variables Window

You can use Command Prompt to clear System and User Env Variables on your Windows PC. Here is how to clear System Env Variables:

  1. Launch Control Panel and select the System symbol.
  2. Select the “Advanced system settings” link on the left side, and if desired, shut the System control panel window.
  3. Select the Env Variables icon with your mouse or tapping device.
  4. Press “Delete” next to the variable you wish to delete at the bottom of the System variables section.
  5. Once you’re finished eliminating system variables, click “OK” to confirm.

To clear the User Env Variables, follow these steps:

  1. Click on the “User Accounts” button in the Control Panel.
  2. On the left, click or tap the “Change my environment variables” link, and if you wish, shut the User Accounts control panel window.
  3. Pick a variable you would like to remove outlined at the top of the User variables for <current user name> section, and press the “Delete” option.
  4. When you’re finished eliminating user variables from your account, select “OK” to confirm the deletion.

Power Shell

Power Shell can also be used to clear both types of Env Variables effectively. Here is how to clear System Env Variables:

  1. Launch a Windows PowerShell session in the elevated mode.
  2. Paste the following command into the elevated PowerShell:
    Get-ChildItem Env:
  3. Hit “Enter” and make a note of the name of the system variable you wish to unset.
  4. Enter the command below into the elevated PowerShell:
    [Environment]::SetEnvironmentVariable("[variable name]",$null,"Machine")
  5. Substitute [variable name] with the variable name you wish to remove in the command above.
  6. You may now exit the elevated Windows PowerShell.

If you want to delete User Env Variable, follow these steps:

  1. Run Windows PowerShell in elevated mode.
  2. In the elevated PowerShell prompt, paste the following command:
    Get-ChildItem Env:
  3. Press “Enter.”
  4. Now type or paste the command below:
    [Environment]::SetEnvironmentVariable("[variable name]",$null,"User")
  5. Hit “Enter” again and close PowerShell.

Registry Editor

Here’s how to clear System Env Variables using Registry Editor:

  1. To launch Registry Editor, press Win + R to open Run, input “regedit” into Run, then click on “OK.”
  2. On the left side of Registry Editor, navigate to the key shown below.
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
  3. Click or press and hold on the value name of the variable you wish to delete on the right side of the Environment key in Registry Editor. Then click or tap on “Delete.”
  4. Confirm by clicking on “Yes.”
  5. Close the Registry Editor.

And to clear user Env Variable, the steps are:

  1. To open Registry Editor, use Win + R to bring up Run, type “regedit” into Run, and then click “OK.”
  2. In the Registry Editor’s left pane, go to the key indicated below.
    HKEY CURRENT USER\Environment
  3. On Registry Editor, click or press and hold the value name of the variable you intend to remove on the right side of the Environment key. After that, select “Delete.”
  4. Confirm your selection by selecting “Yes.”
  5. Ensure that the Registry Editor is closed.

Additional FAQs

Why are Env Variables important?

The answer to the question, “What are environment variables?” is a relatively difficult one. As you can observe from this guide, dealing with Windows programs makes it tough to locate and observe environment variables.

Their management is handled in the background by the OS and the numerous apps and drivers you run on your computer. The OS and your existing programs, on the other hand, rely on them. Your system could malfunction if you mess about with the values of critical system variables without understanding what you’re doing.

What are the default Windows Environment Variables?

Each Windows PC has a vast array of variables. Variables such as OS, TEMP, and PATH are often utilized. You may find default values for Windows environment variables on websites like Wikipedia.

Have Control Over Your Env Variables

The same software used for clearing Env Variables can be used to edit or create new ones as well. However, if you’re not sure about it, it’s better to leave it to a professional. Since the variables are the backbone of your Operating System and software, messing with them can result in a system crash. This can be more expensive than asking a professional to deal with them in the first place.

Have you ever tried to clear Env Variables? Have you tried editing or creating new ones? Did you find it difficult? Let us know in the comment section below!

Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.

Todays Highlights
How to See Google Search History
how to download photos from google photos