1

I'm exploring environment variables via the WMI class Win32_Environment. According to the documentation, a variable that's not of a specific user can be either a "System" variable or a "Default User" variable. My question is, what's the difference, and how I would use one or the other?

Exploring a Windows 2008 machine that's being used as a workstation, I find System variables, but no Default User variables.

JCCyC
  • 670
  • 2
  • 13
  • 24

3 Answers3

5

The SYSTEM variables are those stored in:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

The <DEFAULT> variables are those stored in:

HKEY_USERS\.DEFAULT\Environment

The .DEFAULT user is not the default settings that are created when a user's profile is created for the first time. Rather, .DEFAULT is the HKEY_CURRENT_USER environment used by the LocalSystem security context.

Here's some background from Raymond Chen's blog to give my answer some addt'l credibility: http://blogs.msdn.com/oldnewthing/archive/2007/03/02/1786493.aspx >smile<

Evan Anderson
  • 141,071
  • 19
  • 191
  • 328
1

I'm not quite sure on this one, but most likely the system variables will be available all the time, wherease the Default User variables only apply as long as the user has not overwritten them.

towo
  • 1,887
  • 14
  • 12
  • 1
    Dang; I was writing an answer that you summed up so much easier. Yes, System is system wide, default is persistent until the user changes 'em and user is, well, for that user. As for no default in 2K3, I think its hidden in registry. The GUI doesn't give the option to change defaults unless its a terminal server. This is mainly because you don't have a lot of general users logging into a server (or shouldn't, at least). Since I can't find anything to backup my statement, I'd consider that just a theory. – drgncabe Jul 07 '09 at 16:14
  • @towo: Though it might seem intuitive, this is not correct. – Evan Anderson Jul 07 '09 at 16:21
  • Do you mean, if there's a "PATH" variable for user joeblow, it'll be ignored in favor of the System variable "PATH"? – JCCyC Jul 07 '09 at 17:29
  • 1
    PATH is special. If you set that in a user's registry the entries will be appended to the system path. What I was saying re: this being incorrect relates to the ".DEFAULT" entries "being overridden". The ".DEFAULT" entries are only used by the SYSTEM context. Setting a value in a user's enviroment will override the value specified in the system environment (but has nothing to do with the .DEFAULT values). – Evan Anderson Jul 08 '09 at 03:08
0

Not entirely sure....I would assume System variables are system wide, and there is only 1. Default User variables get set for each user, by default, but are independent of each other. Thus in terminal services for example user a can set his tmpdir to something other than user b but both start with the same value set by the default user.

EasyEcho
  • 754
  • 3
  • 5