Discussion:
SET command for displaying environment variables
(too old to reply)
Stan Brown
2012-02-07 00:19:44 UTC
Permalink
When I type simply SET, I get 94 lines.

When I type SET /V, SET /D, SET /S, and SET /U, the total number of
lines is 88.

I've read the help file carefully, and there doesn't seem to be any
other category that I'm missing. Why don't the four categories add
up to the same number as the plain SET?

I could see if that added up to *more*, if there were some duplicates
among the categories. But I can't see how they can add up to fewer.
--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com
Shikata ga nai...
E. S. Fabian
2012-02-07 01:59:03 UTC
Permalink
Stan Brown:

| When I type simply SET, I get 94 lines.
|
| When I type SET /V, SET /D, SET /S, and SET /U, the total number of
| lines is 88.
|
| I've read the help file carefully, and there doesn't seem to be any
| other category that I'm missing. Why don't the four categories add
| up to the same number as the plain SET?
|
| I could see if that added up to *more*, if there were some duplicates
| among the categories. But I can't see how they can add up to fewer.

The variables accessed by the /d, /s, /u, and /v switches are registry
variables, not environment variables. When Windows starts a process, it
creates environment variables based on the values of the above registry
variables, but it is not a one-for-one process. Usually there is some
overlap between the reqistry variables, in particular, TEMP and TMP are
ofter defined in more than one category.

When you use SET to list environment variables, not only the variables
created by Windows from the registry are listed, but also the variables you
defined using the SET command. Typically there would be more environment
variables than registry variables.
--
HTH, Steve
Stan Brown
2012-02-07 12:42:10 UTC
Permalink
Post by E. S. Fabian
| When I type simply SET, I get 94 lines.
|
| When I type SET /V, SET /D, SET /S, and SET /U, the total number of
| lines is 88.
The variables accessed by the /d, /s, /u, and /v switches are registry
variables, not environment variables. When Windows starts a process, it
creates environment variables based on the values of the above registry
variables, but it is not a one-for-one process. Usually there is some
overlap between the reqistry variables, in particular, TEMP and TMP are
ofter defined in more than one category.
When you use SET to list environment variables, not only the variables
created by Windows from the registry are listed, but also the variables you
defined using the SET command. Typically there would be more environment
variables than registry variables.
Thanks for the reply, Steve. I'll go back and track down exactly
which ones are discrepant. My impression is that it's not variables
created in a command prompt, because I do them all in the registry
these days; but I'll check and report back.

Or is there any way directly to access the environment variables that
don't come from the registry? SET and SET /E each give 94 lines.
--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com
Shikata ga nai...
E. S. Fabian
2012-02-07 14:41:15 UTC
Permalink
Stan Brown:

| Thanks for the reply, Steve. I'll go back and track down exactly
| which ones are discrepant. My impression is that it's not variables
| created in a command prompt, because I do them all in the registry
| these days; but I'll check and report back.

It depends on where in the registry you create them. IIRC I created no
registry variables, and modified only TEMP and TMP. All other of my
variables are true environment variables, created using the SET command. I
regularly work on at least two systems (my dekstop and my laptop), so I have
3 definiton files - one for variables shared by all my systems, and one for
each of my individual systems. These definition files are loaded with SET /R
commands by the TCSTART.BTM program. These variables allow all my batch
files to find other batch files, data files, programs, etc. so I can use the
same command on any system to get the same job done.

| Or is there any way directly to access the environment variables that
| don't come from the registry? SET and SET /E each give 94 lines.

The /E option when displaying environment variables does not do anything. If
is useful only for registry variables.

Windows creates a number of environment variables dynamically, based on the
/s etc. registry variables. There is a hierarchy; I believe all others
override /S. For example, on my WinXP SP3 system TEMP has different
definitions for /S, /D, or /U - the /U shows up in "SET".
--
Steve
Loading...