Skip to main content

Sets persistent environment variables in Windows.

:: To set an environment variable for the current user:
setx <variable> <value>

:: To set an environment variable for the current machine:
setx <variable> <value> /M

:: To set an environment variable for a user on a remote machine:
setx /s <hostname> /u <username> /p <password> <variable> <value>

:: To set an environment variable from a registry key value:
setx <variable> /k <registry\key\path>