WshShell.Environment

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 computer.
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 (for example, c:\).
SYSTEMROOT System directory (for example, c:\winnt). This is the same as WINDIR.
WINDIR System directory (for example, c:\winnt). This is the same as SYSTEMROOT.
TEMP Directory for storing temporary files (for example, c:\temp). User, Volatile
TMP Directory for storing temporary files (for example, 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