How to export and import environment variables in windows?

后端 未结 8 1479
粉色の甜心
粉色の甜心 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 15:52

    A PowerShell script based on @Mithrl's answer

    # export_env.ps1
    $Date = Get-Date
    $DateStr = '{0:dd-MM-yyyy}' -f $Date
    
    mkdir -Force $PWD\env_exports | Out-Null
    
    regedit /e "$PWD\env_exports\user_env_variables[$DateStr].reg" "HKEY_CURRENT_USER\Environment"
    regedit /e "$PWD\env_exports\global_env_variables[$DateStr].reg" "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
    

提交回复
热议问题