Setx creates or modifies environment variables in the user or system environment, without requiring programming or scripting.

The Setx command also retrieves the values of registry keys and writes them to text files.

Setting Environment Variables

Set environment variables permanently, Setx can be used to set Environment Variables for the machine (HKLM) or currently logged on user (HKCU).

> setx <variable> <value> [/m]
  • <variable> - Identifies the variable to be set, e.g. JAVA_HOME, PATH etc.
  • <value> - The variable value, e.g. TEMP C:\Windows\Temp
  • /m - (Optional) Used