Windows Script Host  

WshEnvironment Object

Environment PropertyWshShell Object

Provides access to the collection of Windows environment variables.

Remarks

The WshEnvironment object is a collection of environment variables that is returned by the WshShell object's Environment property. This collection contains the entire set of environment variables (those with names and those without). To retrieve individual environment variables (and their values) from this collection, use the environment variable name as the index.

Example

The following code displays an environment variable.

[VBScript]
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
WScript.Echo WshSysEnv("NUMBER_OF_PROCESSORS")
[JScript]
var WshShell = WScript.CreateObject("WScript.Shell");
var WshSysEnv = WshShell.Environment("SYSTEM");
WScript.Echo(WshSysEnv("NUMBER_OF_PROCESSORS"));

Properties

Item Property | Length Property (WshEnvironment object)

Methods

Count Method | Remove Method

See Also

Environment Property