How to export and import environment variables in windows?

后端 未结 8 1514
粉色の甜心
粉色の甜心 2020-12-22 15:36

I found it is hard to keep my environment variables sync on different machines. I just want to export the settings from one computer and import to other ones.

I thi

8条回答
  •  心在旅途
    2020-12-22 16:03

    Combine @vincsilver and @jdigital's answers with some modifications,

    1. export .reg to current directory
    2. add date mark

    code:

    set TODAY=%DATE:~0,4%-%DATE:~5,2%-%DATE:~8,2%
    
    regedit /e "%CD%\user_env_variables[%TODAY%].reg" "HKEY_CURRENT_USER\Environment"
    regedit /e "%CD%\global_env_variables[%TODAY%].reg" "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
    

    Output would like:

    global_env_variables[2017-02-14].reg
    user_env_variables[2017-02-14].reg
    

提交回复
热议问题