GetEnvironment

GetEnvironment["var"]
gives the setting corresponding to the variable 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.

DetailsDetails

  • 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 .
  • If the variable is found in the environment, the value is a string, possibly empty.
  • If the variable 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.

ExamplesExamplesopen allclose all

Basic Examples (5)Basic Examples (5)

Get a value for the environment variable :

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Value for the undefined environment variable:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Find all defined environment variables:

In[1]:=
Click for copyable input
Out[1]=

Get values for several variables:

In[1]:=
Click for copyable input
Out[1]=

Environment variables are accessible to child processes. On Windows:

In[1]:=
Click for copyable input
Out[1]=

On Unix:

In[2]:=
Click for copyable input
Out[2]=
New in 9
New to Mathematica? Find your learning path »
Have a question? Ask support »