Environment variables in an operating system are a set of dynamic named values that can affect the way running processes will behave on a computer. They include information about the system environment and the currently logged in user.
Note: Environment variables are not limited to Windows operating systems, but for the purpose of this article I will relate to the ones found in the Windows OS.
Environment variables are sometimes used by applications, system services, or other processes to determine various configuration settings about the way the OS is configured, where files are stored in the user’s profile, how many CPU and what CPU architecture the system has, and much, much more.
In the Windows OS there are several types of environment variables. The most widely-known ones are user variables and system variables. However, it may be useful to know that beyond these two there are also process variables and volatile variables.
The way these variables are used is related to their type. For example, user environment variables are accessible to all apps which run in the context of the logged on user, while system environment variables apply to all the users and all the processes that log on and run on that computer. Process variables are used specifically only by specific processes. For example: Software that sets it’s own variables, such as the installation directory, the place where the data is stored, and so on. Volatile variables are variables that only exist and are only true for the current logon session.
So how do we view, and if needed, edit these variables?
There are several methods of editing environment variables in Windows 8, and I’ve listed three of the most common methods below.
Note: Modifying the system or user variables without proper knowledge may lead to a system or application failure. Take care and make sure you have a working backup before experimenting.
The “regular” method for viewing environment variables would be to use the System applet in Control Panel, or by right-clicking “This PC” in Windows Explorer, or by using the Windows Logo + Break keyboard combo.
Note: In older Windows versions, “This PC” used to be called “My Computer”. Same same.
While in there, you need to click on the “Advanced system settings” link on the left pane, and then click on the “Environment Variables” button. Note that the applet separates the user variables from the system variables.
To quickly get to the same applet you can type the following command in a Command Prompt window that was started with elevated credentials (“Run as Administrator”):
You can also create a shortcut for it on the Desktop, and if needed, pin it to the taskbar or even the Start page.
This one has been around since the time of MS-DOS, and still works for viewing the user and system variables.
Open the command prompt window and type the following command:
If you want to view the value of a specific system or user variable, you can use the “echo” command. For example:
and so on.
Many of these variables are stored inside the Windows OS Registry.
Warning! Edit the registry with care, as you do so at your own risk. Always back up the registry before making changes. If you make mistakes or introduce errors, you may not be able to boot the Windows PC with the edited registry. If you don’t feel comfortable editing the registry yourself, find an experienced Windows system administrator to help you complete this task safely.
Log in to the computer using administrative credentials.
Press Win+R keys on your keyboard and type “regedit.exe” (no quotes) into the “Run” dialog box. Click Enter. If you are prompted by UAC, click Yes.
In the Registry editor window:
To see user variables, go to the following key:
To see system variables, go to the following key:
You can pull these values from the Registry and modify them by using multiple programming methods and tools.