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

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

    You can also create a small VBScript script:

    Set env = CreateObject("WScript.Shell").Environment("System")
    If env(WScript.Arguments(0)) <> vbNullString Then env.Remove WScript.Arguments(0)
    

    Then call it like %windir%\System32\cscript.exe //Nologo "script_name.vbs" FOOBAR.

    The disadvantage is you need an extra script, but it does not require a reboot.

提交回复
热议问题