I need to set an environment variable from a Mathematica notebook.
Environment["VARIABLE"]
gives the value of the variable. But is it possible to set a variable, too?
I need to set an environment variable from a Mathematica notebook.
Environment["VARIABLE"]
gives the value of the variable. But is it possible to set a variable, too?
I am assuming you are going to do this before you try to run an external command right? Why not instead just run "VARNAME=value; your_original_external_command" that will temporarily set the evn variable.
There's no built in function (to my knowledge), but you can just use
Run["set VAR=VALUE"]
or
!set VAR=VALUE
instead.
Edit: You'll want to see the documentation for the Run and RunThrough commands.