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.
To set the MACHINE environment variable in the local environment to the value Brand1, type:
To set the MACHINE environment variable in the system environment to the value Brand1 Computer, type:
setx MACHINE "Brand1 Computer" /m
To set the MYPATH environment variable in the local environment to use the search path defined in the PATH environment variable, type:
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:
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 Brand1
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%
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\StandardName
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\StandardName
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" /m
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" /m
To display the contents of a file named Ipconfig.out, along with the contents' corresponding coordinates, type:
To set the IPADDR environment variable in the local environment to the value found at the coordinate 5,11 in the file Ipconfig.out, type:
setx IPADDR /f ipconfig.out /a 5,11
To set the OCTET1 environment variable in the local environment to the value found at the coordinate 5,3 in the file Ipconfig.out with delimiters "#$*.", type:
setx OCTET1 /f ipconfig.out /a 5,3 /d "#$*."
To set the IPGATEWAY environment variable in the local environment to the value found at the coordinate 0,7 with respect to the coordinate of "Gateway" in the file Ipconfig.out, type:
setx IPGATEWAY /f ipconfig.out /r 0,7 Gateway
To display the contents of a file named Ipconfig.out — along with the contents' corresponding coordinates — on a computer named Computer1, type:
setx /s computer1 /u maindom\hiropln /p p@ssW23 /f ipconfig.out /x