Windows setx Command Tutorial

Windows use the environment variables in order to store simple data for different cases. The environment variables can be set for a user or complete system. These are called as user environment variables and system environment variables . The command setx is used in order to set environment variables. Also, the setx command can be used to retrieve registry values.

setx Command Help

The command setx help information can be listed by using the /? . The help information lists the syntax of the setx command, all provided options and parameters.

setx /?
setx Command Help

Create/Set Environment Variable For Current User

The command setx can be used to set or create an environment variable for the current user. The variable name and variable value is provided as parameters. In the following example we set the environment variable named age as the value 37 .

setx age 37

If the variable is set properly and successfully the following message is printed in the command line interface.

SUCCESS: Specified value was saved.

Create/Set Environment Variable For System

The command setx can be also used to set a system environment variable from the command line interface. The system environment variables are accessible and useable by all users in the current system. The option /m is used to set provided environment variable and value system-wide. But this operation requires Administrative privileges where the MS-DOS command-line interface should be opened as Administrator.

setx age 37 /m
See also  Create Symbolic Links (Symlinks) In Windows

Leave a Comment