CmdID

CmdID / Commands

setx

Creates or modifies environment variables in the user or system environment, without requiring programming or scripting. Windows commands reference

On Windows File setx.exe

Opens CmdID with your command. It is read in your browser and sent nowhere.

Windows

from the Windows commands reference, CC BY 4.0

Creates or modifies environment variables in the user or system environment, without requiring programming or scripting. The Setx command also retrieves the values of registry keys and writes them to text files. NOTE: This command provides the only command-line or programmatic way to directly and permanently set system environment values. System environment variables are manually configurable through Control Panel or through a registry editor. The set command, which is internal to the command interpreter (Cmd.exe), sets user environment variables for the current console window only.

setx [/s <computer> [/u [<domain>\]<user name> [/p [<password>]]]] <variable> <value> [/m]
setx [/s <computer> [/u [<domain>\]<user name> [/p [<password>]]]] <variable>] /k <path> [/m]
setx [/s <computer> [/u [<domain>\]<user name> [/p [<password>]]]] /f <filename> {[<variable>] {/a <X>,<Y> | /r <X>,<Y> <String>} [/m] | /x} [/d <delimiters>]

To set the MACHINE environment variable in the local environment to the value Brand1, type

setx MACHINE Brand1Identify

To set the MACHINE environment variable in the system environment to the value Brand1 Computer, type

setx MACHINE Brand1 Computer /mIdentify
/mSpecifies to set the variable in the system environment. Windows commands reference

To set the MYPATH environment variable in the local environment to use the search path defined in the PATH environment variable, type

setx MYPATH %PATH%Identify

To set the MYPATH environment variable in the local environment to use the search path defined in the PATH environment variable after replacing ~ with %, type

setx MYPATH ~PATH~Identify

To set the MACHINE environment variable in the local environment to Brand1 on a remote computer named computer1, type

setx /s computer1 /u maindom\hiropln /p p@ssW23 MACHINE Brand1Identify
/sSpecifies the name or IP address of a remote computer. Windows commands reference
/uRuns the script with the credentials of the specified user account. Windows commands reference
/pSpecifies the password of the user account that is specified in the /u parameter. Windows commands reference

To set the MYPATH environment variable in the local environment to use the search path defined in the PATH environment variable on a remote computer named computer1, type

setx /s computer1 /u maindom\hiropln /p p@ssW23 MYPATH %PATH%Identify
/sSpecifies the name or IP address of a remote computer. Windows commands reference
/uRuns the script with the credentials of the specified user account. Windows commands reference
/pSpecifies the password of the user account that is specified in the /u parameter. Windows commands reference

To set the TZONE environment variable in the local environment to the value found in the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\StandardName registry key, type

setx TZONE /k HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\StandardNameIdentify
/kSpecifies that the variable is set based on information from a registry key. Windows commands reference

To set the TZONE environment variable in the local environment of a remote computer named computer1 to the value found in the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\StandardName registry key, type

setx /s computer1 /u maindom\hiropln /p p@ssW23 TZONE /k HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\StandardNameIdentify
/sSpecifies the name or IP address of a remote computer. Windows commands reference
/uRuns the script with the credentials of the specified user account. Windows commands reference
/pSpecifies the password of the user account that is specified in the /u parameter. Windows commands reference
/kSpecifies that the variable is set based on information from a registry key. Windows commands reference

To set the BUILD environment variable in the system environment to the value found in the HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\CurrentBuildNumber registry key, type

setx BUILD /k HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\CurrentBuildNumber /mIdentify
/kSpecifies that the variable is set based on information from a registry key. Windows commands reference
/mSpecifies to set the variable in the system environment. Windows commands reference

To set the BUILD environment variable in the system environment of a remote computer named Computer1 to the value found in the HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\CurrentBuildNumber registry key, type

setx /s computer1 /u maindom\hiropln /p p@ssW23 BUILD /k HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\CurrentBuildNumber /mIdentify
/sSpecifies the name or IP address of a remote computer. Windows commands reference
/uRuns the script with the credentials of the specified user account. Windows commands reference
/pSpecifies the password of the user account that is specified in the /u parameter. Windows commands reference
/kSpecifies that the variable is set based on information from a registry key. Windows commands reference
/mSpecifies to set the variable in the system environment. Windows commands reference

To display the contents of a file named Ipconfig.out, along with the contents' corresponding coordinates, type

setx /f ipconfig.out /xIdentify
/fSpecifies the file that you want to use. Windows commands reference
/xDisplays file coordinates, ignoring the /a, /r, and /d command-line options. Windows commands reference

To set the IPADDR environment variable in the local environment to the value found at the coordinate *5,11* in the Ipconfig.out file, type

setx IPADDR /f ipconfig.out /a 5,11Identify
/fSpecifies the file that you want to use. Windows commands reference
/aSpecifies absolute coordinates and offset as search parameters. Windows commands reference
Show 13 options
/s <computer>Specifies the name or IP address of a remote computer. Do not use backslashes. The default value is the name of the local computer.
/u [<domain>\]<user name>Runs the script with the credentials of the specified user account. The default value is the system permissions.
/p [<password>]Specifies the password of the user account that is specified in the /u parameter.
<variable>Specifies the name of the environment variable that you want to set.
<value>Specifies the value to which you want to set the environment variable.
/k <path>Specifies that the variable is set based on information from a registry key. The path uses the following syntax: \<HIVE>\<KEY>\...<Value>. For example, you might specify the following path: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\StandardName
/f <filename>Specifies the file that you want 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.
/mSpecifies to set the variable in the system environment. The default setting is the local environment.
/xDisplays file coordinates, ignoring the /a, /r, and /d command-line options.
/d <delimiters>Specifies delimiters such as , or \\ to be used in addition to the four built-in delimiters — SPACE, TAB, ENTER, and LINEFEED. Valid delimiters include any ASCII character. The maximum number of delimiters is 15, including built-in delimiters.
/?Displays help at the command prompt.

Windows

from tldr-pages, CC BY 4.0

Set persistent environment variables.

Set an environment variable for the current user

setx variable valueIdentify

Set an environment variable for the current machine

setx variable value /MIdentify
/MSpecifies to set the variable in the system environment. Windows commands reference

Set an environment variable for a user on a remote machine

setx /s hostname /u username /p password variable valueIdentify
/sSpecifies the name or IP address of a remote computer. Windows commands reference
/uRuns the script with the credentials of the specified user account. Windows commands reference
/pSpecifies the password of the user account that is specified in the /u parameter. Windows commands reference

Set an environment variable from a registry key value

setx variable /k registry\key\pathIdentify
/kSpecifies that the variable is set based on information from a registry key. Windows commands reference