2

When in run

SET TEST_VAR=my_var && echo %TEST_VAR%

I get:

%TEST_VAR%

Which mean I cannot access the setted env var in the current process.

How can I get the TEST_VAR var in the same process ?

I need it in the same process because I'm running this code in dart like this:

import 'dart:io';

void main(List<String> args) {
  Process.run(r"SET TEST_VAR=my_var && echo %TEST_VAR%", [], runInShell: true);
}

Ps: it's not the real command but I'm running a third party code which require some env var to be setted.

Lenny4
  • 121
  • 3
  • If you do `set var=value && program` or simply `set var=value & program` where program is really a program not a CMD builtin like `echo` the program _will_ get the envvar setting, but using it in CMD itself on one line including in /C (or /K) won't. I don't know (anything) about DART, but in Java feeding those commands as (two) different lines of _input_ to CMD (and not commandline) works. – dave_thompson_085 May 28 '23 at 01:25

0 Answers0