Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 580
thejartender Avatar asked Jan 17 '23 16:01

thejartender


1 Answers

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.

like image 85
Hans Passant Avatar answered Jan 23 '23 02:01

Hans Passant