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.
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:
- Launch Control Panel and select the System symbol.
- Select the “Advanced system settings” link on the left side, and if desired, shut the System control panel window.
- Select the Env Variables icon with your mouse or tapping device.
- Press “Delete” next to the variable you wish to delete at the bottom of the System variables section.
- Once you’re finished eliminating system variables, click “OK” to confirm.
To clear the User Env Variables, follow these steps:
- Click on the “User Accounts” button in the Control Panel.
- On the left, click or tap the “Change my environment variables” link, and if you wish, shut the User Accounts control panel window.
- 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.
- When you’re finished eliminating user variables from your account, select “OK” to confirm the deletion.
Power Shell can also be used to clear both types of Env Variables effectively. Here is how to clear System Env Variables:
- Launch a Windows PowerShell session in the elevated mode.
- Paste the following command into the elevated PowerShell:
- Hit “Enter” and make a note of the name of the system variable you wish to unset.
- Enter the command below into the elevated PowerShell:
- Substitute [variable name] with the variable name you wish to remove in the command above.
- You may now exit the elevated Windows PowerShell.
If you want to delete User Env Variable, follow these steps:
- Run Windows PowerShell in elevated mode.
- In the elevated PowerShell prompt, paste the following command:
- Press “Enter.”
- Now type or paste the command below:
- Hit “Enter” again and close PowerShell.
Here’s how to clear System Env Variables using Registry Editor:
- To launch Registry Editor, press Win + R to open Run, input “
regedit” into Run, then click on “OK.”
- On the left side of Registry Editor, navigate to the key shown below.
- 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.”
- Confirm by clicking on “Yes.”
- Close the Registry Editor.
And to clear user Env Variable, the steps are:
- To open Registry Editor, use Win + R to bring up Run, type “
regedit” into Run, and then click “OK.”
- In the Registry Editor’s left pane, go to the key indicated below.
HKEY CURRENT USER\Environment
- 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.”
- Confirm your selection by selecting “Yes.”
- Ensure that the Registry Editor is closed.
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!