Several Methods of Modifying Environment Variables in Windows

Operating environment: Windows 10 Professional Edition
1. Temporary method (it will fail after the current command line window is closed)

set PATH=%PATH%;I:\Users\administrator\AppData\Local\Programs\Python\Python37-32

2. Permanent method:
1. Modify the registry (effective after the current user logs out)
The modified position of "user variable":

[HKCU\Environment

"System Variables" modification location:

[HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment]
[HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]

CurrentControlSet and ControlSet001 save important configuration information for system startup, among which CurrentControlSet points to ControlSet001, and the two are synchronized with each other. Every modification to any branch of the two will be immediately copied to the corresponding key value of the other branch.

2. System configuration modification (the new command line window takes effect)
Open "My Computer"-Properties-Advanced System Settings-Advanced-Environment Variables, you can renew the PATH variable of "User Variables" or "System Variables" according to actual needs Add, modify, delete.

3. The setx command is modified (the new command line window takes effect)

setx path "%path%;I:\Users\administrator\AppData\Local\Programs\Python\Python37-32"

After the modification is completed, note that the newly added environment variable does not take effect in the current cmd window, and a new cmd window needs to be opened. In addition, the environment variables added through the setx command are added in "user variables", not "system variables".

Other TIPS:
The modification of the above commands set and setx is based on the addition of environment variables. I have not found a way to delete them. Welcome to guide. But at least it can be configured by copying the absolute path of all other environment variables required, such as:

setx path "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0"

Reference document:
https://blog.csdn.net/su1322339466/article/details/52983052

Guess you like

Origin blog.csdn.net/szuwangjl/article/details/104272039