WshEnvironment Object
Remove Method
Property: WshEnvironment.Item
object[.
Item]
(lngIndex)
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.
The following VBScript code adds two new environment variables and then displays their values. The example also illustrates the two different forms of syntax available for this default property.
Code:
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Environment("SYSTEM")("MyVar1") = "hello"
objShell.Environment("SYSTEM").Item("MyVar2") = "world"
WScript.Echo objShell.Environment("SYSTEM").Item("MyVar1"), _
objShell.Environment("SYSTEM")("MyVar2")
Output:
hello world
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information