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

Windows has the setx command:

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

So you can set a variable like this:

setx FOOBAR 1

And you can clear the value like this:

setx FOOBAR ""

However, the variable does not get removed. It stays in the registry:

foobar

So how would you actually remove the variable?

10 Answers
10

Leave a Comment