WshShell.Environment

Returns an NT environment variable.

Syntax 
      WshShell.Environment([strType]) 

Arguments:
      [strType] is one of
      "System" (HKLM),
      "User"   (HKCU),
      "Volatile" or "Process"

Example

' Retrieve the %COMPUTERNAME% system environment variable
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshMyEnv = WshShell.Environment("PROCESS")

Wscript.Echo WshMyEnv("COMPUTERNAME") 

Related commands:

expand env variables - WshShell.ExpandEnvironmentStrings
delete env variables - WshShell.WshEnvironment.Remove

Equivalent Windows NT command:

SET - Display, set, or remove Windows NT environment variables



Back to the Top

Simon Sheppard
SS64.com