How To Manage Environment Variables in Windows

Manage Environment Variables In Windows 10Manage Environment Variables In Windows 10

If you are not a Windows power user, chances are you have not heard about Windows environment variables, a set of dynamic variables that can be changed at any time.

Environment variables in Windows are global settings and values that can be accessed by all processes and users. These variables are used to store values that applications and processes can use.

The main purpose of environment variables is to cope with the changes in each new version of the Operating System. There are two types of environment variables in Windows.

  • System Variables
  • User Variables
clip_image001

System variables are used for global variables, meaning changing the system variables will affect all users of the computer. User variables only affect the user currently logged in.

In these two types of variables, there are environment variable types:

  • PATH: This variable stores a list of directories where your OS searches for executable programs. It’s crucial to run commands and launch applications from the command prompt and Run dialog.
  • JAVA_HOME: This variable points to the installation directory of your Java Development Kit (JDK), a necessity for Java development and running Java applications.
  • CLASSPATH: This variable tells your Java Virtual Machine (JVM) where to find user-defined classes and libraries, ensuring your Java code can access the necessary resources.

Note: Please note that environment variables in Windows are not case sensitive and are written in upper case to distinguish between the variable name and the value.

Display environment variables

To display all environment variables in Windows, run the following command in Command Prompt:

C:\set

This command will list down all environment variables on your computer.

Set command to display environment variables in Windows
Set command to display environment variables in Windows

Manage environment variables

Sometimes the user needs to edit the environment variables. Windows provides the option to edit all environment variables in one place, including system variables and user variables.

If you are using Windows 8, follow the instructions below to open the environment variable editor: In Windows Search, select Settings (Windows Key + W) and search for “Environment variables”.

clip_image002

You will see two results:

  • Edit environment variables for your account
  • Edit the system environment variables

Both options are self-explanatory. You can either select to edit the appropriate environment variables. Upon selection, a new window will open with a list of user variables at the top and system variables at the bottom. Here you can add a new variable with its name and value or edit an existing variable.

Let’s take an example scenario to understand the concept of environment variables further. I have some programs that I want to run directly from the Run menu, directly without giving their paths first. This will be a lot easier for me. I should also call the programs or files by their “nicknames”.

Create a folder “E\:tech” and open the environment variables editor as discussed above. Under the system environment variables, edit the Path variable. To add the folder path, append the folder path at the end of the value. The value that should be appended is ;E:\tech. It is important to differentiate between multiple paths.

Now you can put any executable, shortcut or other file in the specified folder, and then run the executable directly by its name without entering the path first. For example, I have put tech.exe in the folder that I can run by going to Run –> tech.

Manage environment variables using third-party software

If anything goes wrong with any important environment variable (like the Path variable which we discussed), some Windows tasks will be affected, and you will not be able to use the Operating System normally. Therefore, it is always advisable to edit or remove the environment variables with great care. We will discuss some third party software to manage and back up environment variables.

Rapid Environment Editor

Rapid Environment Editor (REE) provides a very user-friendly way of editing environment variables. It lists the system variables in the left pane and the user variables in the right pane, while the bottom pane will give details about the selected variable.

The best thing about REE is that it will also highlight a variable if its value has some errors. You can also back up the environment variable configuration from the file menu. Rapid Environment Editor comes with an installable program, as well as a portable one. If you are using the portable REE in Windows 7 or Windows 8, you will need to run the executable in the administrative mode so that it can make changes to the system configuration.

clip_image003

Rapid Environment Editor

PathMan

PathMan is a very simple portable program, which will only edit the PATH environment variable. Since PATH is a variable that needs to be edited frequently, PathMan can help edit Path environment variable directly from the USB drive.
clip_image004

PathMan

Eveditor

Eveditor comes with an elegant and very user-friendly graphical user interface which resembles the look and feel of Windows Explorer. You can choose from a user variable or system variable from the pane on the left. The selection will be displayed on the right-hand pane. The details of the selected environment variable will be displayed in the bottom pane.

You can edit the selected variable, and upon clicking the “Set” button, the variable will be saved. Please note that you will need to run Eveditor with administrative privileges in order to save the environment variables successfully.clip_image005Eveditor

Conclusion

On our end, it is always recommended to back it up before you make changes to your system.  You can either back up the Windows environment variable configuration using Rapid Environment Editor, or the complete Windows configuration using Windows 8 File History Tool.

If you ever want to edit the environment variables, third-party software will make it easier to manage and revert the values. For what purposes do you edit environment variables? Tell us some interesting uses.

If you liked this post, Share it on:
Usman Khurshid is a seasoned IT Pro with over 15 years of experience in the IT industry. He has experience in everything from IT support, helpdesk, sysadmin, network admin, and cloud computing. He is also certified in Microsoft Technologies (MCTS and MCSA) and also Cisco Certified Professional in Routing and Switching.

12 comments

  • kamran

    unfortunately deleted the path of environmental and i am unable to run java programmer please give me some some advice and how to set the path.

  • eran

    Hi
    Im using win8.1. And I can’t add or edit system variables,buttons are disabled . I’m the admin on my PC.

    Any solution please?
    Thank you!

    • Usman Khurshid
      A
      Usman Khurshid

      Can you create a new admin account? If yes then create a new account with administrative privileges and try to change the system variables in that account. If you are able to do it then there is a problem with your account. We can sort out the problem after you have confirmed this.

  • Eric

    And if I want to manage the variables from command line, is it possible and easy?

    • Usman Khurshid
      A
      Usman Khurshid

      Yes you can easily set the environment variables using command line. SET is the appropriate command for this purpose. SET /? will give you all options you can use with SET command.

      • roshan

        PLEASE HELP SAME PROBLEM OF I deleted all my environment variables but one while screwing around with my new computer. Now I can’t seem to install new programs, and worst of all, cannot go back into Advanced System Preferences to re-add the environment variables I deleted. How do I fix this, and also, what environment variables do I need to add again so that my computer will work right? AND MY OS IS WIN 8

        • Usman Khurshid
          A
          Usman Khurshid

          You will need to add the following system variables again in order for Windows to work properly:
          PATH= %SystemRoot%system32;%SystemRoot%
          OS= .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
          TEMP= %SystemRoot%TEMP
          TMP= %SystemRoot%TEMP
          WINDIR= %SystemRoot%

          Please let me know if this solves your problem.

          • aman paudel
            aman paudel

            i have same problem how can i solve that problem

  • Eric

    What about Windows 8? What are the default variable values for Windows 8 and Windows 7?

  • Eric

    I deleted all my environment variables but one while screwing around with my new computer. Now I can’t seem to install new programs, and worst of all, cannot go back into Advanced System Preferences to re-add the environment variables I deleted. How do I fix this, and also, what environment variables do I need to add again so that my computer will work right?

    • Usman Khurshid
      A
      Usman Khurshid

      That really depends upon which version of Windows you’re running. Can you tell me the version of Windows: Windows XP, Vista, 7, 8, 8.1?

      • Ishwarya
        Ishwarya

        I do have the same problem currently iam using windows 8 can you please help me

Get Updates in Your Inbox

Sign up for the regular updates and be the first to know about the latest tech information