Windows Tools

SetX Syntax

Overview | Notes | Syntax | Related Tools Open Command Prompt

SetX uses the following general syntax:

One Step setx [Parameters]

Command-Line Mode

One Step setx Variable Value [/m]

Parameters

Variable
Specifies the name of the environment variable to set.
Value
Specifies the value to which the environment variable will be set.
/m
Specifies that the value being set is in the system environment. The default is the user environment.

Sample Usage

setx machine compaq
setx machine "COMPAQ COMPUTER" /m
setx mypath %path%
setx mypath ~PATH~

File Mode

One Step setx Variable /f FileName {/a XCoordinate , YCoordinate|/r XCoordinate , YCoordinate " String "} [/d {Delimiter] [/x] [/m]

Parameters

/f FileName
Specifies the name of the file to use.
/a XCoordinate , YCoordinate
Specifies absolute coordinates and offset as search parameters.
/r XCoordinate , YCoordinate " String "
Specifies relative coordinates and offset from String as search parameters.
/d Delimiter
Specifies additional delimiters (d) such as "," or "\".

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

/x
Displays file coordinates. The /a, /r, and /d parameters are ignored when /x is specified.
/m
Specifies that the value being set is in the system environment. The default is the user environment.

Sample Usage

setx var /f ipconfig.out -x
setx ipaddr /f ipconfig.out /a 5,11
setx octet1 /f ipconfig.out /a 5,3 /d .
setx ipgateway /f ipconfig.out /r 0,7 "Gateway"

Registry Mode

One Step setx Variable /k Hive\Key\...\Value [/m]

Parameters

Variable
Specifies the name of the environment variable to set.
/k
Specifies that the variable is set based on information from a registry key.
Hive\Key\...\Value
Specifies the registry path to the value for the environment 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.

Sample Usage

setx tzone /k HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInform ation\StandardName
setx build /k "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\CurrentBuildNumber"

Note