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

前端 未结 9 1134
闹比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:47

    To remove the variable from the current command session without removing it permanently, use the regular built-in set command - just put nothing after the equals sign:

    set FOOBAR=

    To confirm, run set with no arguments and check the current environment. The variable should be missing from the list entirely.

    Note: this will only remove the variable from the current environment - it will not persist the change to the registry. When a new command process is started, the variable will be back.

提交回复
热议问题