NT Syntax

SETX.exe (Resource Kit)

SETX: Set environment variables permanently

IMPORTANT: SETX writes variables to the master environment in the registry. Variables set using SETX are only available in future command windows and not in the current command window.

SETX can be used in 3 modes:

1) Set Environment Variables for the machine or currently logged on user:

     SETX variable value [-m] 
-m Sets value in the Machine environment. Default is User.

2) Registry Mode: see the newer REG command for this

3) File Mode: Edit CR-LF text files, (like win.ini) for more information use: SETX -i


SETX v_machine COMPAQ
Sets value of v_machine to be COMPAQ in the users environment.
this is the same as the command SET v_machine=COMPAQ

Sets value of v_machine to be "COMPAQ COMPUTER" in the machine environment.

SETX v_mypath %PATH%
Sets the value of v_mypath to the CURRENT value of the PATH environment variable.

SETX v_mypath ~PATH~
Sets the value of v_mypath to ALWAYS be equal to the value of the PATH environment variable even in the event that the PATH variable changes.

Registry Size
This can be increased in the control panel or from

"You are never dedicated to something you have complete confidence in. No-one is fanatically shouting that the sun is going to rise tomorrow. When people are fanatically devoted to political or religious faiths or any other kind of dogmas or goals, its always because these dogmas or goals are in doubt" - Robert T Pirsig

Related Commands:

SET - Display, set, or remove Windows NT environment variables

Equivalent Linux BASH commands:

env - Display, set, or remove environment variables
export - Set an environment variable

Simon Sheppard