How to see names and values of environment variables in Windows 8 and Windows 7

Environment variables in an operating system are values that contain information about the system environment, and the currently logged in user. They existed in OSes before Windows as well, such as MS-DOS. Applications or services can use the information defined by environment variables to determine various things about the OS, for example, to detect the number of processes, the currently logged in user's name, the folder path to the current user's profile or the temporary files directory. In this article, we will see how to view environment variables defined on your system and their values for the current user, for specific processes and the system variables.

Windows has several types of environment variables: user variables, system variables, process variables and volatile variables. User environment variables are accessible to all apps which run in the current user context, system environment variables apply to all users and processes on the PC; process variables are applicable only to a specific process and volatile variables are those which exist only for the current logon session. Most interesting of these are user, system and process variables, as we can modify them.

How to view user and system environment variables and their values

The most simple way to view the current user variables is to use the System Properties.

  1. Open the Control Panel.
  2. Navigate to the following applet:
    Control Panel\System and Security\System

    system properties

  3. Click the "Advanced System Settings" link on the left.In the next dialog, you will see the Environment Variables... button in the bottom of the Advanced tab. Click it.
    environment variables button
  4. The Environment Variables window will appear on the screen.
    environment variables window
    In the upper table, you will see user variables, and the bottom list contains system-wide variables.
    Here you can view their names and values or even create your own variables, or edit the value of some variable if required.

There are several other ways to see environment variables.
You can see them at the appropriate registry keys.

  1. Open Registry Editor.
  2. To see user variables, go to the following key:
    HKEY_CURRENT_USER\Environment

    Tip: How to jump to the desired registry key with one click.
    hkcu_variables

  3. To see system variables, navigate to the following key:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

    hklm_variables

Alternatively, you can view environment variables via the command prompt. Open the command prompt window, and type the following command and then press Enter:

set

The set command will print all available environment variables with their values, directly into the console output, so you will able to see them all at once.
set
If you want to see the value of a specific variable, then use the echo command instead of set, as follows:
echo %userprofile%
The command above will print the path to your account profile.
echo_userprofile
Replace userprofile with the desired name of the variable. For example, echo %computername%. That's it.

How to see environment variables for a specific Windows process

Unfortunately, I know no native way (i.e. without using third party apps) to view variables of some application running in Windows, but the Sysinternals Process Explorer does this perfectly.

  1. Download Process Explorer and run it as Administrator.
  2. Right click the process that you are interested in and choose "Properties..." from the context menu.
  3. The properties window for that process will appear on the screen. Switch to the Environment tab and see the complete set of variables for the selected process. This is very useful.
    totalcmd64
    In my screenshot, you can see the COMMANDER_PATH variable, which is available exclusively for Total Commander (the totalcmd64.exe process). If I type "cd %commander_path%" in Total Commander's command line, it will jump into the directory where it is installed.

That's it. Now you know all the useful ways to see the names and values of variables defined in your Windows environment.

2 thoughts on “How to see names and values of environment variables in Windows 8 and Windows 7

  1. Liibaan Abdikarin

    thanks for this explanation.

    Like or Dislike: Thumb up 0 Thumb down 0

    Reply
    1. Sergey Tkachenko Post author

      You are welcome.

      Like or Dislike: Thumb up 0 Thumb down 0

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *