Menu Close

How to Set, Edit and Delete Environment Variables in Windows

How to set, edit, and delete environment variables in windows 11

In this article, we are going to see how to set, edit and delete environment variables in Windows 11 operating system along with step by step guide with the help of appropriate screenshots. Different-2 programs require different environment variable settings to be executed.
The environment is mainly used to store the information about the system environment running in the current machine.

Basically, The meaning of setting the environment variable is creating a shortcut to start a program instead of remembering the location of the program. By creating the environment you can start the program just by typing a single keyword.
That’s why it is one of the most important for windows users to know how to set environment variables in windows 11.

What is Environment Variable in Windows?

The environment variable is the process of setting the dynamic variable value in the machine. In other words, the Environment variable is the way to store the global variable value that is used by all the processes and users that are running under the machine. Environment variables represent the new software installation directory location, Windows Operating system file location, etc. The value of the environment variable is used by the programs to determine where the files are stored actually.

These are some common environment variables available in the windows operating system.

  • Path:- Path is one of the most popular environment variables in the windows operating system that is used to store the list of directories to search for executable programs and also it is one of the most frequently used environment variables.
  • Username:- This is for the username of the system.
  • OS:- The operating system name.

There are other environment variables available except all of the above.

Why You Need to Environment Variable

Windows Environment variables are used to store the data that are used by windows and other programs. For example, windir environment variable stores the location of the Windows installation directory. Programs can query the value of this variable to find where the files of the Windows operating system are located.

There are two types of environment variables available in windows machines first are system variables and the second is user variables that are logged in. Logged-in users can only change their own environment variable if they don’t have administration permission even another user can not change the environment variable.

Let’s take another example about environment variable so that you can get more clarity, Suppose you are going to install Python on your machine and then during the installation of the Python it will ask you, to add a python executable file to your environment variable if you do not check that setting and continue the installation. After successfully the installation of Python you are ready to execute any Python script but you have to remember one thing each time you have to specify the location of the Python executable to execute the Python script but if you check that setting during the installation then you don’t need to specify the location of the Python executable each time.

But after the installation of Python or any software you can manually set the environment variable.

Let’s see how can you set a new environment variable in your windows 11 machine.

Note:- All the variable names which I will set, edit and delete throughout this article will just be for testing. You can set your own required environment variable.

How to Set Environment Variables in Windows 11?

With the help of the following points you can set your environment variable in your windows machine.Here I will go with windows 11 machine.

  • To set the environment variable in Windows you have to right-click on This PC icon and again click on Properties.
  • Now you have to click on “Advanced system settings“.
  • Click on “Environment Variables“.
  • After clicking on Environment variables, you can see all your system environment variables ( User and System ) very clearly.
    1. User Variables:- User variable will contain environment variables about the current logged-in user, If you want to change the environment variable of the logged-in user then you have to change it inside this variables section.
    2. System Variables:- System variable contains variables and values system-wide.This variable will be available for all the users across the machine which means it is a system-wide change.

You can choose according to your need. Here I am going with User variables.

  • After deciding your appropriate environment variables section, click on New.
  • Now, It will ask you to provide the variable name and value of the variable. Here I am setting the Java executable environment variable and after that click OK until all the open environment variables windows are gone.

So finally we have seen the whole process to set new environment variables in the windows 11 machine.

How to Change the Environment Variable in Windows 11

Here I’m gonna show you, how you can change or edit the environment variable.

  • To change the environment variable, press “Windows + R” and type “sysdm.cpl” and hit enter.
  • Go to Advanced > Environment variables section
  • Select the environment variable which you want to change and click edit
  • Provide variable name and variable value as your wish and then click Ok

How to Delete Environment Variable in windows 11

Sometimes you require to delete existing environment variables. With the help of these steps, you can delete any existing environment variables.

  • To delete the environment variable, press “Windows + R” and type “sysdm.cpl” and hit enter.
  • Go to Advanced > Environment variables section.
  • Select the environment variable which you want to delete and click delete.
  • After clicking on delete, your environment variables will be deleted successfully.

How to Set Environment Variable using Command Prompt

Windows command prompt also provides us with some useful commands to work with windows environment variables. here I am going to show how to set environment variables using a command prompt.

  • First, you need to open your command prompt, To open the command prompt press “Windows + R” and type “cmd“, and hit enter.
  • Windows provide a useful command “set” to set the environment variable. The syntax for setting the new environment variable is that set variable_name=variable_value. Here I am going to set an environment variable website=Proogramming Funda so my whole command would be set website=Proogramming Funda.

To verify whether the environment variable was created or not, you can execute the set command. This command shows all the environment variables with values.

Changing environment variable using command prompt

To change the existing environment variable, you have re-assign the value of the existing environment variable by using the following command.

set variable_name=variable_value

Note:- Make sure you are not going to change the variable name.

Access Environment Variable using Command Prompt

To access the existing environment variable in the windows machine, Open the command prompt and issue the set variable_name statement.
Here variable_name represents the name of the variable which you want to access.

As you can see from below the screenshot, I am accessing the website environment variable.

Setting Environment Variable using Windows Powershell

Here I’m gonna show you can set, edit and delete the environment variable using Windows PowerShell.

  • To open Powershell, Press “Windows + R” type “PowerShell” and hit enter.
  • The following is the syntax of the setting new environment variable in windows with help of the windows PowerShell.
$Env:<variable-name> = value

In the above syntax, variable-name represents the name of the variable which you want to keep, and the value represents the value of a variable.

So here I am going to set a variable name website along with the value “Programming Funda“.

How to Access Environment Variable using Powershell

  • To access the existing environment variable using Windows Powershell, Search “Powershell” in the search bar and open windows power shell.
  • The syntax for accessing the environment variable is “$Env:variable_name“. Here I am going to see the value of an environment variable named website.

Changing Environment Variable using Windows PowerShell

If you want to change the value of the existing environment variable using windows PowerShell, Then you have to re-assign the value of the environment variable. As you can see below the image.

Deleting Environment Variable using Windows Powershell

To delete the environment variable in a windows machine using PowerShell you have to assign the blank string to that variable. As you can see below screenshot.

Conclusion

So in this article, we have seen all about how to set, edit, and delete environment variables in windows 11. Here I have more than one method to set, delete and edit windows environment variables as per your choice.

Environment variables is basically a process of storing variables and their values globally in the system so that programs, processes, and users determine where the configuration files, installation directory, drivers, and executable
are stored.

I hope this article is very useful for you. If you like this article please share and keep visiting for further interesting tutorials.

Ref:- Click Here

Thanks for your valuable time …

Previous Article
Next Article

Related Posts