System Variables vs User Variables | Difference


👤 Diwas Poudel    🕒 23 Apr 2022    📁 TECH

Environment variables are dynamic variables that hold values related to the current working environment and can be used by the operating system, users, processes, and other applications to obtain necessary information such as OS information (e.g. computer name, temp location, account names, current working direction, search path for files, and so on) and other working environment information as well.

These variables assist the software in understanding the system's behaviour and have an impact on how the OS, applications, and processes run.

Environment Variables are in key-value format, and the values can be edited. These key/values pairs can be used by one or more Windows applications.

As an example, TEMP is an environment variable used to determine the location of temporary files.TEMP refers to the application's temporary folder location. As a result, we can say that its value is the temporary location's path. So, to get the temp location, type %temp% and then press Enter in the run.

Environment Variables is available on all major operating systems, including Windows, Mac, and Linux. There are mainly two types of environment variable one are user-dependent, and another is user-independent, meaning they remain the same for all users in the system. Those two environment variables are:

  • System Variables
  • User Variables

let's discuss each of them and their differences.

User Variables 

User Variables contain user-specific information and are specific to the current login. The User Account in Windows OS has the ability to edit its user variables. If you have two user accounts on the computer, each will have a separate copy of this information. One User account user variable will be unknown to another User account. 

As a result, when you log in with one user and go to the environment, you may see user profiles that are different from when you logged in with another user. They can be manually configured by the logged-in user.

They contain information such as the location of account temporary files, one drive files,  user profile, the path of the application and the bin location of various applications to be used by the user etc.

You can find system variables by navigating to the following path.

1 Open run and type below command

rundll32.exe sysdm.cpl,EditEnvironmentVariables

and press Enter. This will open Environment Variables.

2 Then you will get User variables under the User Variables Label.

uservariables
fig. User Variables List

You can get the same using Powershell with the following Command:

 reg query HKEY_CURRENT_USER\Environment
user-variables-list
fig. User Variables List using Powershell

System Variables 

System variables do not contain user-specific information because they are set the same for each user account on your computer. They are global variables that apply to all user accounts. These are the variables generated by the operating system, device drivers, and programs.

You must have the administrative privilege to change or add system variables. As they contain critical system information and do not recommend changing or deleting the key/value of those variables if you are unknown about those key/value of system variables.

They contain information such as the folder where Windows is installed, the computer name, the user name, the location of the drivers, the number of processors, the OS type, the processor identifier, the processor architecture, the processor level, and so on.

System Variable's names are normally uppercase with words separated by an underscore(_). For example PROCESSOR_ARCHITECTURE

The following are some of the most common system variables: %programfiles%, %systemroot%, %data% %windir%,%NUMBER_OF_PROCESSORS% ,%PATH% etc.

Why System Variables?

When you install Windows OS, Windows will automatically create system variables with the name WINDIR and the value will be the location of Windows Installation Files. You can see this by typing %windir% in a run and pressing Enter.

It will look at system environment variables and find out windir name and navigate to its value which is Windows Installation Location. When you install any application, if it requires the Windows installation location, it will look at these system variables with the name windir and then install the application in the same folder when necessary.

Also read: How to list all environment variables?

This is one of the most used cases used by third-party applications.

You can find system variables by navigating to the following path.

1 Open run and type below command and press Enter.

rundll32.exe sysdm.cpl,EditEnvironmentVariables

This will open Environment Variables.

2 Then you will get System variables under System Variables Label.

systemvariables
fig. System Variables List

You can get the same using Powershell with the following Command:

Get-ChildItem Env
listofsystemvariables
fig. List of System Variables using Powershell

System Variables vs User Variables

Now let's look differences between System Variables and User Variables in tabular format:

System Variables User Variables
They are non-user-specific variables. They are user-specific variables.
Every login user cannot change system variables. Every login user can change their specific user variables.
With Admin Privilege you can change System Variables. You do not need admin privileges to change its own user variables.
These variables are created usually by Operating systems, Device Drivers and Programs. These variables are user-specific variables so users can create their own variables.
To get all system environment variable type: Get-ChildItem Env:  in PowerShell To get all user variables type:  reg query HKEY_CURRENT_USER\Environment in Powershell.
Example:%programfiles%, %systemroot%,windir,NUMBER_OF_PROCESSORS etc. Example: ANDROID_HOME, OneDrive

FAQ:

💡 What if I remove system variables?

Ans: If you delete system variables, there is a greater chance that you will be unable to open and locate some programs.The solution is to restore the factory settings by resetting the same variables to environment variables.

💡 Can I modify System Variables?

Ans: You cannot change user environment variables if you are using a Standard user account. It's true and should not allow each user to log in and change the environment variable.  It is a Windows security feature. However, if the user has administrative privileges, you can change them.

🗒 Note: Please keep in mind that deleting either user or system variables may require you to log off and on again before your changes to environment variables take effect.

Conclusion:

From this article, you must have clearly understood the difference between system variables and user variables.