Show environment variable:
CMD
echo %ENVIRONMENT_VARIABLE%
Powershell
Get-ChildItem Env:ENVIRONMENT_VARIABLE
Show all environment variables:
CMD
SET
Powershell
Get-ChildItem Env:
Set the environment variable:
CMD
SET PYTHONHOME=C:\python33
PowerShell
$env:TestVariable = "This is a test environment variable."
[Environment]::SetEnvironmentVariable("TESTVARIABLE", "VALUE")
Permanent Setting & Unsetting:
Use setx http://technet.microsoft.com/en-us/library/cc755104.aspx
Create
setx FOOBAR 1
Clear
setx FOOBAR ""
Delete from User
REG delete HKCU\Environment /F /V FOOBAR
Delete from System
REG delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /F /V FOOBAR
If you're running these commands from Cygwin, make sure to escape any backslashes.
This requires a restart on the terminal, even if you're in Cygwin.
Show environment variable:
echo $ENVIRONMENT_VARIABLE
Show all environment variables:
env
Set environment variable:
export ENVIRONMENT_VARIABLE="value"
Unset environment variable:
unset ENVIRONMENT_VARIABLE
Permanent Setting & Unsetting:
Use your initial script like .bashrc
or .zshrc
.