1

Before the question show, i use cmd order path = %path%D:\test to add a root in PATH(eniroment variable).When i use cmd order echo %path% , it shows:

D:\VMware Workstation Pro\bin\;C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files (x86)\dotnet\;D:\ffmpeg\bin;D:\mingw64\bin;D:\py3.7\Scripts\;D:\py3.7\;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;D:\Microsoft VS Code\bin;D:\ffmpeg\bin;D:\test

But,when i go into the computer property, it shows:

Computer property shows:

Obviously, D:\Test is lost in the the PATH in the computer property of the enviroment value PATH.

I want to know why and how to fix the problem.

Thank you.

1 Answer 1

1

Why is the path is different in a cmd shell and the system property?

If you use set to change an environment variable the changes are only valid for the current command shell.

  • set - Display, set, or remove CMD environment variables. Changes made with SET will remain only for the duration of the current CMD session.

To make a permanent change use setx instead.

  • setx - Set environment variables permanently, SETX can be used to set Environment Variables for the machine (HKLM) or currently logged on user (HKCU)

Further reading

2
  • do you mean like this >setx path=%path%C:\Test; I tried this , but it tells me ERROR: Invalid syntax. Type "SETX /?" for usage.
    – Danhui Xu
    Commented Aug 22, 2022 at 0:53
  • Use setx path %path%C:\Test
    – DavidPostill
    Commented Aug 22, 2022 at 5:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .