Windows 10 environment variables

You don’t have to be a programmer to have to deal with environment variables in some case . It may be, for example, that when installing or configuring a Windows program you have come across a path that, instead of following the typical structure “C: / Users / net2 / folder” shows something like “% USERPROFILE% / folder ” .

That’s because % USERPROFILE% is an environment variable: that is, a text string that operating systems like Windows use to store values that can vary from one computer to another or, as in this case, from one user to another but which nevertheless need a unified way of accessing it.

What are environment variables anyway ?

Typically, these ​​refer to common system files, directories and functions whose specific path may vary , but which other programs need to know.

The example above allows a program to know how to access your user folder even if you have not indicated its name . Or even if it doesn’t know which version of Windows you are using ( remember that Windows 10’s ‘C: \ Users \’ was ‘C: \ Document and Settings \’ in Windows XP).

Read: How to speed up your Windows computer

It does not matter, because all that information is defined in the environment variables, guaranteeing that all Windows programs can carry out their work correctly on any computer. Because there are many more environment variables besides % USERPROFILE% . Here are some:

  • % APPDATA% – Refers to the hidden folder for program data, inside the user box. In Windows 10 the default path is “C: \ Users \ Username \ AppData \ Roaming”.
  • % COMMONPROGRAMFILES % – Refers to the folder where programs store common files. In Windows 10 the default path is “C: \ Program Files \ Common Files”
  • % PROGRAMFILES % – Refers to the folder where programs are installed. In Windows 10 the default path is “C: \ Program Files” .
  • % WINDIR % – Refers to the folder where Windows is installed. In Windows 10 the default path is “C: \ Windows” .

But environment variables don’t always store directory paths: they can refer to other kinds of information . Thus, % TIME% returns the current system time, % OS% the operating system version and % PATHEXT% the list of file extensions considered executable (the list usually includes, in addition to the .EXE, files such as .BAT, .COM, .CMD, .JS., .JSE, .MSC, .VBE, .VBS, .WSF, .WSH, etc).

%PATH% environment variable

Perhaps the environment variable that you will most often have to deal with will be % PATH% . What is its function? Have you noticed that, when you type in your own Windows command (for example, Regedit ), it is not necessary to write the full path of the executable ?

Read: How is the path environment variable managed in Linux/Ubuntu/Debian?

That is because, every time you invoke a command, the system checks the folders contained in the % PATH% variable to check if any executable file matches it .

It is a resource widely used, for example, by developers who want to call an interpreter or compiler from the project folder they are working on; many IDEs also turn to % PATH% to run such tools.

Here is what happens when we call the Java interpreter without including the JRE directory in the Windows% PATH % :

Java

Check and edit environment variables in Windows 10

If you want to check if the values ​​of these variables on your computer match those shown here, you can open a command line window (CMD, not the Power Shell) and type in “ECHO” followed by the variable in question.

If you prefer to list all the variables and their respective values , go to the Power Shell and write “Get-ChildItem Env:” .

How to set environment variables in windows 10 using a graphical interface

If you don’t like to use the command line, there is another tool that will allow you not only to check the value of each variable, but also to edit them very easily.

You would first need to open the system properties window by right-clicking on the Start button and choosing the System option . A new window will open up. Next, click on ‘Advanced system settings’ link as shown below.

A new window will show up in which you would need to select the tab ‘Advanced’ , and then click on ‘Environment variables’ button on the bottom.

Here you will see all the PATH variables (both user and system environment’s) used by your operating system.


set environment variable windows

Once you reach this point, you would only have to select the variable that you are interested in changing and click “Edit”. You can also add new variables or remove them.


If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.

 

Nikolaus Oosterhof

Nikolaus has a degree in software development. He is passionate about gadgets with a screen, nostalgic for phones, a retired gamer and open source programmer. He likes also to write about macOS and Windows. design web pages and debug long programs!

Leave a Reply