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.
set var=value && program
or simplyset var=value & program
where program is really a program not a CMD builtin likeecho
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.