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.

1
  • 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. Commented May 28, 2023 at 1:25

0

You must log in to answer this question.

Browse other questions tagged .