I need to remove system variables from client workstations. I have 500+ clients, so I want to provide batch file to user to run himself to delete the system variables.
The setx command with an empty string value doesn't delete it. And that is not just nitpicking, because the logic is quite different. Because if the user specific variable overrides a global variable, then it is not possible to remove the user specific variable and have the global variable "become active" again. The empty string user specific variable blocks the global variable. One need to actually DELETE it (using the Evironment Variables window) to achieve that.
I just today tried this, with the global variable JAVA_HOME being overridden by a user specific JAVA_HOME. It was not possible to make the global varialble active again without deleting the user specific variable completely. And so far I have not seen a method to do that from the command line or batch script.
(Not enough reputation points to add comment to the above answer about setx, so have to add my own answer...)
You will need to modify this registry key:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment
Changes are effective after rebooting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With