On Sunday, 3 February 2013 at 19:05:01 UTC, Peter Sommerfeld wrote:
Do you know a way to set it via system/shell calls, notably under windows?

Peter
You might want to use Tango:

module env;
// 2013-01-08
// dmd2.061 + Siegelord Tango-D2-d2port

import tango.sys.Environment;
import tango.io.Stdout;

void main(string[] args)
{
    string VAR = "TESTENVVAR";
    string VAL1 = "VAL1";
    string VAL2 = "VAL2";

    assert(Environment.get(VAR) is null);

    Environment.set(VAR, VAL1);
    assert(Environment.get(VAR) == VAL1);

    Environment.set(VAR, "");
    assert(Environment.get(VAR) is null);

    Environment.set(VAR, VAL2);
    assert(Environment.get(VAR) == VAL2);

    Environment.set(VAR, null);
    assert(Environment.get(VAR) is null);

    Environment.set(VAR, VAL1);

    foreach (key, value; Environment.get)
        Stdout.formatln("'{}' = '{}'", key, value);

    foreach(i, arg; args)
    {
        auto p = Environment.exePath (cast (char[]) arg);
Stdout.formatln("exePath(arg[{}] '{}') = '{}'", i, arg, p);
    }
}

Reply via email to