Permanently setting Windows environment variables from scripts (e.g. PowerShell)

To permanently set Windows environment variables (e.g. PATH) from a (PowerShell) script, you can use setx or Set-ItemProperty like this (for the current user):

setx VARIABLE value
Set-ItemProperty -Path 'Registry::HKEY_CURRENT_USER\Environment' -Name VARIABLE -Value "value"

And here is the result:

Setting Environment Variables From A Script

Über Stefan

Polyglot Clean Code Developer

Ein Kommentar

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see