HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

setx — Set persistent environment variables. More information: <https://learn.microsoft.com/windows-server/

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandsetxclienvironmentpersistentvariablessetmore
windows

Problem

How to use the setx command: Set persistent environment variables. More information: <https://learn.microsoft.com/windows-server/administration/windows-commands/setx>.

Solution

setx — Set persistent environment variables. More information: <https://learn.microsoft.com/windows-server/administration/windows-commands/setx>.

Set an environment variable for the current user:
setx {{variable}} {{value}}


Set an environment variable for the current machine:
setx {{variable}} {{value}} /M


Set an environment variable for a user on a remote machine:
setx /s {{hostname}} /u {{username}} /p {{password}} {{variable}} {{value}}


Set an environment variable from a registry key value:
setx {{variable}} /k {{registry\key\path}}

Code Snippets

Set an environment variable for the current user

setx {{variable}} {{value}}

Set an environment variable for the current machine

setx {{variable}} {{value}} /M

Set an environment variable for a user on a remote machine

setx /s {{hostname}} /u {{username}} /p {{password}} {{variable}} {{value}}

Set an environment variable from a registry key value

setx {{variable}} /k {{registry\key\path}}

Context

tldr-pages: windows/setx

Revisions (0)

No revisions yet.