A common technique to change Windows shell environment variables from C++ is the write an env file, that is then “called” from the script.
del env.var foo.exe ## writes to env.var call env.var