Windows has the
Description: Creates or modifies environment variables in the user or system environment.
You can set a variable like this
setx FOOBAR 1
And you can erase that value like this
setx FOOBAR ""
However, the variable does not get removed. It's on the registry
How would you remove this variable?
To remove the variable from the current environment ( not permanently).
To permanently remove the variable from the user environment (which is the default place
setx puts it).
REG delete HKCU\Environment /F /V FOOBAR
If the variable is set in the system environment (e.g. if you originally set it with
setx /M ), as an administrator run.
REG delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /F /V FOOBAR
REG commands above won't affect any existing processes (and some new processes that are forked from existing processes), so if it's important for the change to take effect immediately, the easiest and surest thing to do is log out and back in or reboot. If this is not an option or you want to dig further some of the other answers here have some good suggestions that may suit your needs