Skip to content

Instantly share code, notes, and snippets.

@cotyembry
Created December 23, 2016 05:17
Show Gist options
  • Save cotyembry/fab380e4e9e4c2a1051b657954cd1a34 to your computer and use it in GitHub Desktop.
Save cotyembry/fab380e4e9e4c2a1051b657954cd1a34 to your computer and use it in GitHub Desktop.
to create a persistent variable in windows cmd in the terminal/command prompt you can type
setx variableName value
Now variableName will be available in every cmd session after exiting out of the current cmd.exe session.
It is a persistent, how amazing.
to echo it, i.e. print it out, do
echo %variableName%
to delete a persistent variable that was previously created with setx do
To remove the variable from the user environment (which is the default place setx puts it) use:
REG delete HKCU\Environment /F /V variableName
if you originally set it with setx /M as administrator use:
REG delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /F /V variableName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment