Windows - std.process - Setting env variables from D

Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 30 05:57:21 PDT 2015


On Monday, 30 March 2015 at 12:28:19 UTC, wobbles wrote:
> I'm trying to set environment variables that will be visible 
> when my D program exits.
> It is possible in a windows batch file using the set command 
> (like set "VAR=VALUE" )
>
> However, running this in D using:
>
> import std.process;
> import std.stdio;
>
> void main(){
>
> auto pid1 = spawnShell(`set "VAR=VALUE"`);
> pid1.wait();
> auto pid2 = spawnShell(`set`);
> pid2.wait();
> }
>
>
> however, upon exit, there is no VAR=VALUE in the environment.
>
> Using std.process.environment["VAR"]= "VALUE"; doesnt store the 
> variable in the parent either.
>
> Any solutions that people know of?

Type setx /? in the command shell.  (Note the x).

http://stackoverflow.com/questions/5898131/set-a-persistent-environment-variable-from-cmd-exe


More information about the Digitalmars-d-learn mailing list