Setx creates or modifies environment variables in the user or system environment, without requiring programming or scripting.
The Setx command also retrieves the values of registry keys and writes them to text files.
Setting Environment Variables
Set environment variables permanently, Setx can be used to set Environment Variables for the machine (HKLM) or currently logged on user (HKCU).
> setx <variable> <value> [/m]
<variable>- Identifies the variable to be set, e.g.
<value>- The variable value, e.g.
/m- (Optional) Used to indicate that it is a System variable.
Clearing Environment Variables
To clear an environment variable using
Setx.exe at a command prompt:
Click Start, point to Programs, and then click Command Prompt.
To clear a user environment variable, type the following line
> setx <variable> ""
<variable> is the user environment variable.
To clear a system environment variable, type the following line
> setx <variable> "" -m
<variable> is the system environment variable.
Close the command prompt.
Setx.exe to clear an environment variable value does not affect the variable name.