Windows - std.process - Setting env variables from D

wobbles via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 30 05:28:18 PDT 2015


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?


More information about the Digitalmars-d-learn mailing list