Command line to remove an environment variable from the OS level configuration

前端 未结 9 1133
闹比i
闹比i 2020-11-30 17:11

Windows has the setx command:

Description:
    Creates or modifies environment variables in the user or system
    environment.

So you can

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 17:42

    I agree with CupawnTae.

    SET is not useful for changes to the master environment.

    FYI: System variables are in HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment (a good deal longer than user vars).

    The full command for a system var named FOOBAR therefore is:

    REG delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /F /V FOOBAR
    

    (Note the quotes required to handle the space.)

    It is too bad the setx command doesn't support a delete syntax. :(

    PS: Use responsibly - If you kill your path variable, don't blame me!

提交回复
热议问题