in reply to Changing parent process environment variable

Have the child output the set commands instead of executing it, and process the commands in the parent.

If the parent is a Perl script:

chomp( my @cmds = `child` ); foreach my $cmd (@cmds) { next unless /^set\s+(\S.*?)=(.*)/i; $ENV{$1} = $2; }

If the parent is a batch file:

for /f "usebackq delims=" %%f in (`child`) do %%f

The child would output such as

echo set VAR=5
or
print("set VAR=5\n");

Update: Added second snippet.