GetEnvironment

GetEnvironment["var"]

gives the setting corresponding to the variable "var" in the operating system environment.

GetEnvironment[{"var1","var2",}]

gives a list of rules, corresponding to specified environment variables.

GetEnvironment[]

gives information about all existing settings in the operating system environment.

Details

  • GetEnvironment[All] is the same as GetEnvironment[].
  • GetEnvironment returns results in the form "var"->value, where value is the value of a corresponding environment variable "var".
  • If the variable "var" is found in the environment, the value is a string, possibly empty.
  • If the variable "var" is not defined in the environment, GetEnvironment returns "var"->None.
  • Names and values of the variables defined in the operating system environment depend on the computer system you are using.

Examples

Basic Examples  (5)

Get a value for the environment variable "HOME":

Value for the undefined environment variable:

Find all defined environment variables:

Get values for several variables:

Environment variables are accessible to child processes. On Windows:

On Unix:

Introduced in 2012
 (9.0)