Windows

setx

CautionSet env vars permanently

setx <VAR> "<value>"

Persists env vars (/m = machine-wide). Beware the 1024-char limit — it can truncate PATH.

Examples

  • setx JAVA_HOME "C:\jdk21" /mSet a machine-wide variable

Syntax

setx <VAR> <value> [/m]

Before you run it

Rewriting PATH via setx risks truncation.

Related commands

  • setShow/set env vars (session)
  • regRegistry from the CLI

The same reference, with no signal at all

Every command and flow from this site, held on your device and searchable with no connection. Free to install, no ads.

Get it free on the App Store