Home > Commands N-Z > Commands S


Description | Syntax | Parameters | Switches | Related | Notes | Examples | Errorlevels | Availability

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 [-i]

SETX [/s computer [/u [domain\]user [/p [password]]]] variable string [/m]

SETX [/s computer [/u [domain\]user [/p [password]]]] [variable] /k path [/m]

SETX [/s computer [/u [domain\]user [/p [password]]]] /f file_name [variable] [/a X,y | /r X,y "string"] [/m] [/d delimiters]

SETX [/s computer [/u [domain\]user [/p [password]]]] /f file_name [variable] [/m] [/x]

string (NT4)
Specifies the string you want to associate with the specified variable.
variable (NT4)
Specifies the variable you want to set or modify. Variables are not case sensitive.

/? (NT2003)
Display command help.
/a X,y (NT2003)
Specifies absolute coordinates and offset as search parameters.
/d delimiters (NT2003)
Specifies additional delimiters such as "," or "\". The four built-in delimiters are SPACE, TAB, ENTER, and LINEFEED. You can use any ASCII character as an additional delimiter. The maximum number of delimiters, including the four built-in delimiters, is 15.
/f file_name (NT2003)
Specifies the file that you want to use.
File mode supports the parsing of CR-LF text files only.
-i (NT4 ONLY)
Edit CR-LF text files, (like win.ini).
/k path (NT2003)
Specifies that the variable is set based on information from a registry key. Specify Path in the \HIVE\KEY\...\Value format.
HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE are the only supported hives. REG_DWORD, REG_EXPAND_SZ, REG_SZ AND REG_MULTI_SZ are the valid RegKey data types.
When gaining access to REG_MULTI_SZ values in the registry, only the first item is extracted and used.
REG_DWORD registry values are extracted and used in hexadecimal mode.
/m (NT4)
Sets value in the Machine (system) environment. Default is User (local).
/p [password] (NT2003)
Specifies the password of the user account that is specified in /u.
/r X,y "string" (NT2003)
Specifies relative coordinates and offset from "string" as search parameters.
/s computer (NT2003)
Specifies the name or IP address of a remote computer (do not use backslashes). The default is the local computer. Applies to all files and folders specified in the command.
/u [domain\]user (NT2003)
Runs the script with the permissions of the specified user account. The default is system permissions.
/x (NT2003)
Displays file coordinates.


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.


Registry Size can be increased in the control panel or from HKLM\SYSTEM\CurrentControlSet\Control\RegistrySizeLimit


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

    SETX v_machine COMPAQ

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

    SETX v_machine "COMPAQ COMPUTER" -m

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:

    SETX v_mypath ~PATH~



External Resource Kit
Windows NT
NT4 NT2003