Archive

More than once I needed to define a permanent Environment Variable on a Windows machine – mostly as part of some automatic installation process. E.g. – like the Java installer sets the JAVA_HOME during installation.

Windows has a very simple utility to do so – SETX.

# Set the variable HELLO with the value "WORLD" for the current user
SETX HELLO WORLD
# Set the variable HELLO with the value "WORLD" for all users (System)
SETX HELLO WORLD /m

Note that SETX is different from SET – invoking SETX as part of a shell script will not make the variable available for that shell script.