WshShell.Environment

[This is preliminary documentation and subject to change.]

The Environment property returns the WshEnvironment object.

Syntax

WshShell.Environment ( [strType]) = objWshEnvironment
 

Remarks

If strType specifies where the environment variable resides, possible values are "System", "User", "Volatile", and "Process". If strType is not supplied, this method retrieves the system environment variables in Windows NT or the process environment variables in Windows 95.

For Windows 95, only "Process" is supported in the strType parameter.

The following variables are provided with the Windows operating system. Scripts can also get environment variables that were set by other applications.

Name Description
NUMBER_OF_PROCESSORS Number of processors running on the machine
PROCESSOR_ARCHITECTURE Processor type of the user's workstation
PROCESSOR_IDENTIFIER Processor ID of the user's workstation
PROCESSOR_LEVEL Processor level of the user's workstation
PROCESSOR_REVISION Processor version of the user's workstation
OS Operating system on the user's workstation
COMSPEC Executable for command Command Prompt (typically cmd.exe)
HOMEDRIVE Primary local drive (typically the C drive)
HOMEPATH Default directory for users (on Windows NT this is typically \users\default
PATH PATH environment variable
PATHEXT Extensions for executable files (typically .com, .exe, .bat, or .cmd)
PROMPT Command prompt (typically $P$G)
SYSTEMDRIVE Local drive on which system directory resides (e.g., c:\)
SYSTEMROOT System directory (e.g., c:\winnt). This is the same as WINDIR
WINDIR System directory (e.g., c:\winnt). This is the same as SYSTEMROOT
TEMP Directory for storing temporary files (e.g., c:\temp). User, Volatile
TMP Directory for storing temporary files (e.g., c:\temp). User, Volatile

Example

' Retrieve the NUMBER_OF_PROCESSORS system environment variable
    Set WshShell = Wscript.CreateObject("Wscript.Shell")

    Set WshSysEnv = WshShell.Environment("SYSTEM")
    Wscript.Echo WshSysEnv("NUMBER_OF_PROCESSORS")

See Also

WshEnvironment object

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.