Setx.exe


This command-line tool offers a batch method for setting environmental variables in the user or system environment and requires no programming or scripting. In addition to taking an environmental variable and its associated value from the command line, it can also get the values of registrykeys and write them to text files.

SetX provides the only command-line or programmatic way to directly set system environment values for Microsoft Windows 2000. System environment variables are manually configureable through Control Panels or through a registry editor (Regedit or Regedt32). The SET command, which is internal to the command interpreter (Cmd.exe), sets only user environment variables for the current console window.

You can use SetX to set values for user and system environment variables from one of three sources: Command Line Mode, Registry Mode, or File Mode.

To display command-line options and details about syntax for all three modes, type:
setx /? or setx (without parameters)


For additional information and examples for all three modes, type:
setx -i

Note

File Required

SetX Topics


top

Command-Line Mode Syntax


setx variable value [-m]

Where:

variable
is the name of the environmental variable to be set.
value
is the value to which the environmental variable will be set.
-m
specifies that the value being set is in the system environment. The default is the user environment.

top

Registry Mode Syntax


setx variable -k hive\key\...\value [-m]

Where:

variable
is the name of the environmental variable to be set.
-k
specifies that the variable is set based on information from a registry key.
hive\key\...\value
is the registry path to the value for the environmental variable. For example: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\StandardName
-m
specifies that the value being set is in the system environment. The default is the user environment.

top

File Mode Syntax


setx variable -f filename {-a x,y | -r x,y "string"} [-d d] [-x] [-m]

Where:

-f filename
specifies the name of the file to use.
-a x,y
specifies absolute coordinates and offset as search parameters.
-r x,y "string"
specifies relative coordinates and offset from string as search parameters.
-d d
specifies additional delimiters (d) such as "," or "\".

The 4 built-in delimiters are space, tab, carriage return and linefeed. Any ASCII character can be used as an additional delimiter. The maximum number of delimiters, including the 4 built-in ones, is 15.

-x
displays file coordinates. Switches -a, -r, and -d are ignored.
-m
specifies that the value being set is in the system environment. The default is the user environment.

top

Known Limitations


The following list contains known limitations for setx: