Have you ever wondered about environment variables? Maybe some IT admin or computer geek was mentioning them. Or some program started malfunctioning and returning errors referring to environment variables. Whatever the reason you want to learn more about them, you arrived at the right place. This article will show you everything you need to know about what they are, how they work and why they are important in Windows:
What are environment variables in Windows?
Environment variables are, in short, variables that describe the environment in which programs run. They are used by all kinds of programs to answer questions like: What is the name of the computer where I am installed? What is the name of the user account that is running me? What is my current working directory? Where is Windows installed? Where are the temporary files stored on this computer? Where is the OneDrive folder for this user account?
In Windows, environment variables have a name and value. For example, the variable windir (short for “Windows directory”) may have the value “C:\Windows” or another path where Windows is installed.
Another common variable is named PATH. Many programs need to know where to find certain files, and the PATH variable tells them where they can find what they need. Those programs look for a PATH variable automatically, so you don’t have to type it all in every time you run the program. This variable has a value consisting of many user directories. These directories are set by the different programs that are installed on the computer, and they vary widely from system to system.
The concept of environment variables exists in most operating systems, from Linux to OS X to Windows. In principle, they mean the same thing but the way they are implemented and used differs.
Types of environment variables: User and System
There are two types of variables: user variables, specific to each user account, and system variables that apply to all user accounts.
User environment variables have values that differ from user to user. As their name implies, they are specific to your user account, and they store user specific data, like the location of your user profile, the folder where temporary files are stored for your account, the location of your OneDrive folder, and so on. They can be edited by that user account but not by other user accounts. These variables can be set by the user, by Windows or by different programs working with user specific locations.
System variables are global and cannot be changed by any user. Their values are the same for all user accounts. They refer to locations of critical system resources, like the folder where Windows is installed, the location of Program Files, and so on. These variables are set by Windows, by different programs and drivers.
How to find the environment variables in Windows
Viewing the environment variables configured in Windows involves quite a few steps. In Windows 10, use Cortana’s search box and type environment. Then, click or tap on the “Edit the system environment variables” search result. If you prefer speaking to Cortana, say “Open environment variables,“ and she will open them for you.
In Windows 7, type environment in the Start Menu search box and two search results are displayed: “Edit environment variables for your account” and “Edit the system environment variables.” Click on either of them.
In Windows 8.1, type the word environment while on the Start screen, and two search results are displayed: “Edit environment variables for your account” and “Edit the system environment variables.” Click or tap either of them.
The Environment Variables window is opened. There are some minor visual differences between Windows versions. In the screenshot below you can see how this window looks in Windows 10 (on the left) and Windows 7 (on the right). The options and buttons available are the same and work the same way, no matter which Windows version you are using.
How to access the environment variables from the Control Panel
Alternatively, you can use the Control Panel to access your environment variables. The upside is that this method works the same in all versions of Windows. If you don’t know how to open the Control Panel, use 8 ways to start the Control Panel in Windows 10.
In the Control Panel, go to System and Security and then to System. In the column on the left, click or tap “Advanced system settings.” This opens the System Properties window. Then, in the Advanced tab, click the Environment Variables button highlighted below.
The Environment Variables window is opened. On the top, it displays your user’s variables, and on the bottom, it shows the system variables, valid for all user accounts existing in Windows.
How to access the environment variables from the Run window
You can also use the Run window (Windows + R) to access your environment variables if you know what command to type. In this window, type the command “systempropertiesadvanced.exe” and press Enter or click OK.
The System Properties window opens. Then, in the Advanced tab, click or tap the Environment Variables button.
How to view environment variables in the Command Prompt or PowerShell
If you are a fan of the Command Prompt, you can see all the environment variables by typing the command: SET, without any other parameters. Start the Command Prompt in Windows, type set, and press Enter.
If you prefer PowerShell, open it, type the command “Get-ChildItem Env:” without the quotes but with the : at the end, and press Enter.
All the environment variables are listed, but they are not split depending on their type (user or system variables).
Which are the standard environment variables in Windows?
There is a long list of variables existing on each Windows computer. The most used are variables like OS, PATH, and TEMP. You can find the entire list and all their default values on Wikipedia: Environment variables – Default Values on Microsoft Windows.
As you can see from this tutorial, environment variables are neither easy to find nor visible in any way, while working with Windows programs. They are managed in the background by the operating system and the different programs and drivers you install. However, they are essential to the proper operation of the operating system and of your installed apps. If you change the value of important system variables, without knowing what you are doing, you will get to experience just how important these environment variables are, by causing your system to malfunction. 🙂