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.
gives information about all existing settings in the operating system environment.
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.
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":
GetEnvironment["HOME"]Environment["HOME"]Value for the undefined environment variable:
GetEnvironment["MYHOME"]Environment["MYHOME"]Find all defined environment variables:
First /@ GetEnvironment[]Get values for several variables:
GetEnvironment[{"HOMEDIR", "HOMEDRIVE", "HOMEPATH"}]Environment variables are accessible to child processes. On Windows:
SetEnvironment["FOO" -> "1"]
Import["!echo %FOO%", "Text"]SetEnvironment["FOO" -> "1"]
Import["!echo $FOO", "Text"]See Also
Related Guides
History
Text
Wolfram Research (2012), GetEnvironment, Wolfram Language function, https://reference.wolfram.com/language/ref/GetEnvironment.html.
CMS
Wolfram Language. 2012. "GetEnvironment." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/GetEnvironment.html.
APA
Wolfram Language. (2012). GetEnvironment. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GetEnvironment.html
BibTeX
@misc{reference.wolfram_2026_getenvironment, author="Wolfram Research", title="{GetEnvironment}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/GetEnvironment.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_getenvironment, organization={Wolfram Research}, title={GetEnvironment}, year={2012}, url={https://reference.wolfram.com/language/ref/GetEnvironment.html}, note=[Accessed: 12-June-2026]}