Skip to content

Instantly share code, notes, and snippets.

@mitchmindtree
Created October 21, 2018 08:42
Show Gist options
  • Save mitchmindtree/92c8e37fa80c8dddee5b94fc88d1288b to your computer and use it in GitHub Desktop.
Save mitchmindtree/92c8e37fa80c8dddee5b94fc88d1288b to your computer and use it in GitHub Desktop.
How to permanently set user environment variables on Windows

Setting an Environment Variable on Windows

Here are three ways you can set the user environment variable FOO with the value path\to\foo so that the variable persists across sessions.

  1. Using the command prompt:
    setx FOO "path\to\foo"
    
  2. Using powershell:
    [Environment]::SetEnvironmentVariable("FOO", "path\to\foo", [System.EnvironmentVariableTarget]::User)
    
  3. Using the windows GUI.
    1. Open the start menu.
    2. Search for the "Advanced System Settings" control panel and click on it.
    3. Click on the "Environment Variables" button toward the bottom of the screen.
    4. Follow the prompts to add the variable to the user table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment