OBJECT:  WshEnvironment

The WshEnvironment object is a read/write collection object that contains the environment variables. This object cannot be instantiated directly. It can only be accessed through the WshShell.Environment property.

As with all collection objects, the WshEnvironment collection can be iterated using the VBScript "For Each .. In" statement, but cannot be iterated using the JScript "for .. in" syntax. Since the Item property takes a String argument, this means that there is effectively no way to iterate this collection in JScript. When iterated using the VBScript "For Each ... In" syntax, the values assigned to the loop variable are of the form "Name=Value".

PROPERTIES

Item Property
The Item property is the default property of the WshEnvironment object. It takes a single argument of type String, and returns the value of the environment variable with the specified name, or the empty string if no such environment variable exists in the collection. When used on the left hand side of an assignment operation, this property adds a new environment variable with the specified name, and assigns it the specified value.

Syntax: object[.Item](strName)

length Property
The length property is read only and returns a Long value which is the number of items in the collection. For JScript consistency, length should be lowercase.

Syntax: object.Length


 
METHODS

Count Method
The Count method returns a Long value which is the number of items in the collection.

Syntax: object.Count()

Remove Method
The Remove method deletes the environment variable with the specified name. If no such environment variable exists, a runtime error will be generated.

Syntax: object.RemovestrName


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information