WshEnvironment.Item

The Item property sets or returns the value for the strName environment variable. It is the default property.

Syntax

WshEnvironment.Item("strName") = strValue
WshEnvironment("strName") = strValue
 

Example

' Get the value of NUMBER_OF_PROCESSORS environment variable
  Set WshShell = Wscript.CreateObject("Wscript.Shell")
  Set WshSysEnv = WshShell.Environment("SYSTEM")
  Wscript.Echo WshSysEnv("NUMBER_OF_PROCESSORS")

' Set the value of EXAMPLE volatile environment variable to A_VALUE
  Set WshShell = Wscript.CreateObject("Wscript.Shell")
  Set WshEnv = WshShell.Environment("VOLATILE")
  WshEnv("EXAMPLE")= "A_VALUE"

' List all system environment variables
  Set WshShell = Wscript.CreateObject("Wscript.Shell")
  For Each strVarName In WshShell.Environment("SYSTEM")
    MsgBox strVarName
  Next

See Also

WshShell.Environment property