What is the difference between system and environment variables regarding Windows?

15,614

Solution 1

Variables like %SystemRoot% and %WinDir% are just plain environment variables. The only difference is where their values come from:

  • The system environment variables are predefined and determined by setup. This Technet article, "Using environment variables with Cmd.exe" section, lists their names, do note that it is out of date and doesn't cover 64-bit specific variables
  • The configurable system wide environment variables defined in the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment registry key, effective for any user
  • The configurable user specific environment variables defined in the HKEY_CURRENT_USER\Environment registry key.

The effective process environment is a merge of these three sources.

The latter two registry keys can be edited from the Control Panel + System applet, Environment Variables button. Beware that making the changes effective may require a logoff + logon so the process starts with a fresh copy of the environment instead of a stale one it inherits from its parent process.

Solution 2

Environment variables are 'evaluated' (ie. they are attributed) in the following order:

System variables Variables defined in autoexec.bat User variables Every process has an environment block that contains a set of environment variables and their values. There are two types of environment variables: user environment variables (set for each user) and system environment variables (set for everyone). A child process inherits the environment variables of its parent process by default.

Programs started by the command processor inherit the command processor's environment variables.

Environment variables specify search paths for files, directories for temporary files, application-specific options, and other similar information. The system maintains an environment block for each user and one for the computer. The system environment block represents environment variables for all users of the particular computer. A user's environment block represents the environment variables the system maintains for that particular user, including the set of system environment variables.

Solution 3

My understanding is that the 'system' option is only available to the administrator account. Choosing this option will provide all users with the variable values. The environment variable for non admin users and the can override values with their own desired values. This second option will have no effect on other accounts on the system.

Defining a system variable requires system restart to update you system. If using the command prompt and the environment option, you simply need a fresh or new prompt to make use of the variable you defined.

Share:
15,614
thejartender
Author by

thejartender

All you need to know about me is that I never give up. I learned Java programming from 2007 and took Vendor certifications. Unknowingly I had a brain tumor for many years before being diagnosed in 2010 with an orange-sized Anaplastic Astrocytoma. I endured 4 brain surgeries, 6 weeks chemo-radiotherapy and 10 months chemotherapy before getting back to what I love in 2012 when I launched http://thejarbar.org and http://buhaugane.com Oops 2012 and it happens again New tumor new surgery. Read about my life and support cancer (please) http://www.news24.com/MyNews24/Lack-of-brain-cancer-awareness-cost-me-Astrocytoma-20121011 AGAIN!! 2013 and diagnosed with my third tumor in as many years only more aggressive. Never giving up :)

Updated on June 05, 2022

Comments

  • thejartender
    thejartender almost 2 years

    There are two methodologies to defining environment variables on Windows. I have seen examples using 'system' variables and mere 'environment' ones. What are the differences and consequences to using the one method over the other?