|Purpose:||Remove variables from the environment or the registry|
|Format:||UNSET [/D /E /Q /S /U /V /R file... (name ...)] name [name...]}]|
|name||One or more variables to remove (wildcards accepted except for registry variables).|
|file||One or more files from which to read variables to be removed.|
UNSET removes one or more variables from the environment or from the Windows Registry.
You can also use regular expressions in the variable name.
Note: You cannot use UNSET with GOSUB variables.
Use caution when removing environment variables, and especially when using UNSET *. Many programs will not work properly without certain environment variables; for example, TCC depends on PATH.
Registry Variables: Default, System, User, and Volatile registry variables can be manipulated with the UNSET command's /D, /S, /U and /V switches, respectively. To remove the variable from both the registry and from the local environment, use both the /E switch and the registry variable selection switch together. (You cannot use wildcards for the variable name.) For example, to remove the volatile variable myvar from both the registry and the local environment, use:
unset /v /e myvar
Use caution when directly removing registry variables as they may be essential to various Windows processes and applications.
To remove the environment variable CMDLINE:
If you use the command UNSET *, all of the environment variables will be deleted:
You can delete all matching variables except for those specified by enclosing the exceptions in parentheses. For example, to remove all variables beginning with "v" except for var1 and var2:
unset (var1 var2) v*
|/E||When used together with one of /D, /S, /U, or /V, unsets both the registry variable and the local environment variable.|
|/R||Read environment variables to be UNSET from a file. This is much faster than using multiple UNSET commands in a batch file, and can be more selective than UNSET *. The file format may be the same as that used by the SET /R command (see SET for more details), or it could just be one variable per line, wildcards not processed.|
UNSET /R will read from STDIN if no filename is present and input is redirected.
|/S||Delete a system variable from the registry (HKLM\System\CurrentControlSet\Control\Session Manager\Environment).|