How can I change Windows shell (cmd.exe) environment variables from C++?

前端 未结 4 994
耶瑟儿~
耶瑟儿~ 2021-01-07 09:20

I would like to write a program that sets an environment variable in an instance of the shell (cmd.exe) it was called from. The idea is that I could store some state in thi

4条回答
  •  忘掉有多难
    2021-01-07 09:46

    A common techniques is the write an env file, that is then "call"ed from the script.

    del env.var
    foo.exe ## writes to env.var
    call env.var
    

提交回复
热议问题