setx [/ s [/ u [] [/ p []]]] [] / k [/ m]
setx [/ s [/ u [] [/ p []]] / f {[] {/ a, | / r, ""} [/ m] | / x} [/ d]
Setx command parameter
Parameters
Describe
/S
Specify the name or IP address of the remote computer.Do not use backslashes in this parameter.The default value will be the name of the local computer.
/ u []
Run the script with the login information of the specified user account.The default value will be system rights.
/ p []
Specify the password of the user account specified in the parameter / u.
Specify the name of the environment variable you want to set.
Specify the value for which you want to set the environment variable.
/ k
Specifying that the variable is set based on information from the registry key, the Path parameter will use the following syntax:
.
. For example, you can specify the following path:
HKEY_LOCAL_MACHINESystemCurrentControlSet
ControlTimeZoneInformationStandardName
/ f
Specify the file you want to use.
/ a,
Specify absolute coordinates and blank extra spaces as search parameters.
/ r, ""
Specify relative coordinates and empty space (String) as the search parameter.
/ m
Specify variable settings in the system environment.The default setting will be the local environment.
/ x
Display file coordinates, ignore command line options / a, / r and / d.
/ d
Specifying the separators as "," or "" will be used along with four integrated delimiters - SPACE, TAB, ENTER and LINEFEED.Valid delimiters include any ASCII characters.The maximum number of separators is 15, including integrated delimiters.
/?
Show help at thecommand prompt.
Setx command comment
Example setx command
To set an environment variable with the name MACHINE in a local environment to Brand1, enter:
setx MACHINE Brand1
To set an environment variable with the name MACHINE in the system environment to Brand1 Computer value, enter:
setx MACHINE "Brand1 Computer" / m
To set an environment variable named MYPATH in a local environment using the search path specified in the PATH environment variable, enter:
setx MYPATH% PATH%
To set an environment variable named MYPATH in a local environment, use the search path specified in the PATH environment variable after replacing ~ with%, type:
setx MYPATH ~ PATH ~
To place an environment variable with the name MACHINE in a local environment to Brand1 on a remote computer named Computer1, type:
setx / s computer1 / u maindomhiropln / pp @ ssW23 MACHINE Brand1
To set an environment variable named MYPATH in a local environment, use the search path specified in the PATH environment variable on the remote computer named Computer1, type:
setx / s computer1 / u maindomhiropln / pp @ ssW23 MYPATH% PATH%
To set the environment variable named TZONE in the local environment to the value found in the HKEY_LOCAL_MACHINESystemCurrentControlSetControl registry key
TimeZoneIn informationStandardName, type:
setx TZONE / k HKEY_LOCAL_MACHINESystemCurrentControlSetControlTimeZoneInformationStandardName
To set the environment variable named TZONE in the local environment of the remote computer named Computer1 to the value found in the HKEY_LOCAL_MACHINESystemCurrentControlSetControl registry key
TimeZoneInformStandardName, type:
setx / s computer1 / u maindomhiropln / pp @ ssW23 TZONE / k HKEY_LOCAL_MACHINESystemCurrentControlSetControlTimeZoneInformationStandardName
To set the BUILD environment variable in the system environment to the value found in the registry key HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsNTCurrentVersion
CurrentBuildNumber, please enter:
setx BUILD / k "HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsNTCurrentVersionCurrentBuildNumber" / m
To set the BUILD environment variable in the system environment of the remote computer named Computer1 to the value found in the registry key HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsNT
CurrentVersionCurrentBuildNumber, type:
setx / s computer1 / u maindomhiropln / pp @ ssW23 BUILD / k "HKEY_LOCAL_MACHINESoftwareMicrosoftWindows NTCurrentVersionCurrentBuildNumber" / m
To display the contents of the file named Ipconfig.out, along with the corresponding coordinates of the content, enter:
setx / f ipconfig.out / x
To set the environment variable named IPADDR in the local environment to the value found at the 5.11 file in Ipconfig.out file, type:
setx IPADDR / f ipconfig.out / a 5.11
To set the environment variable named OCTET1 in the local environment to the value found at 5.3 coordinates in Ipconfig.out file with "# $ *." Delimiters, type:
setx OCTET1 / f ipconfig.out / a 5.3 / d "# $ *."
To set an environment variable named IPGATEWAY in a local environment to a value found at 0.7 coordinates for the "Gateway" coordinates in Ipconfig.out file, enter:
setx IPGATEWAY / f ipconfig.out / r 0.7 Gateway
To display the contents of the file named Ipconfig.out - along with the corresponding coordinates of the content - on the computer named Computer1, enter:
setx / s computer1 / u maindomhiropln / pp @ ssW23 / f ipconfig.out / x
See more: