What are Environment Variables?

User & System Environment Variables & How To Find Their Values

Photo of equations on a blackboard
© XH creation / Getty Images

An environment variable is a dynamic value that the operating system and other software can use to determine information specific to your computer.

In other words, an environment variable is something that represents something else, like a location on your computer, a version number, a list of objects, etc.

Environment variables are surrounded by the percent sign (%), as in %temp%, to distinguish them from regular text.

Two types of environment variables exist, user environment variables and system environment variables, both of which you can read more about below:

User Environment Variables

User environment variables, as the name suggests, are environment variables that are specific to each user account.

This means that the value of an environment variable when logged in as one user can be different than the value of the same environment variable when logged in as a different user on the same computer.

These types of environment variables can be manually set by whatever user is logged in but Windows and other software can set them as well.

One example of a user environment variable is %homepath%. On my Windows 10 computer, %homepath% holds the value of \Users\Tim, which is the folder that contains all of my user-specific information.

A user environment variable could be a custom, as well. I could create something like %data%, which may point to a folder on my computer like C:\Downloads\Files.

An environment variable like this would only work when I'm logged in.

System Environment Variables

System environment variables extend beyond just one user, applying to any user that might exist, or is created in the future. Most system environment variables point to important locations like the Windows folder.

Some of the most common environment variables in Windows systems include %path%, %programfiles%, %temp%, and %systemroot%, though there are many others.

For example, when you install Windows 8, the %windir% environment variable is set to the directory in which it's installed to. Since the installation directory is something the installer (that's you... or your computer maker) can define in one computer, it might be C:\Windows, but in another, it may be C:\Win8.

Continuing with this example, let's say Microsoft Word is installed on each of these computers after Windows 8 is done setting up. As part of the Word installation process, a number of files need to be copied to the directory that Windows 8 is installed in. How can MS Word be sure it's installing the files in the right place if that place is C:\Windows on one computer and C:\Win8 on the other?

To prevent a potential problem like this, Microsoft Word, as well as most software, was designed to install to %windir%, not C:\Windows. This way, it can be sure that these important files are installed in the same directory as Windows 8, no matter where that might be.

See Microsoft's Recognized Environment Variables page for a giant list of user and system environment variables often used in Windows.

How Do You Find the Value of an Environment Variable?

There are several ways to see what a particular environment variable happens to be. However, in most cases, at least in Windows, the most simple, and probably fastest, way to do this is via a simple Command Prompt command called echo.

Here's how to do it:

  1. Open Command Prompt.
     
  2. Execute the following command exactly:
    echo %temp%
    
    ...of course substituting %temp% for the environment variable you're interested in.
     
  3. Note the value that's displayed immediately underneath.

    For example, on my computer, echo %temp% produced this:
    C:\Users\Tim\AppData\Local\Temp

    If the Command Prompt scares you (it shouldn't), there's a longer way to check out the value of an environment variable without using command line tools.

    Head to Control Panel, then the System applet. Once there, choose Advanced system settings on the left, then choose the Environment Variables... button at the bottom. This is an incomplete list of environment variables but the ones that are listed have the values right next to them.