SET — Set or display an environment variable


SET [/?] [name[=value]]


Display command syntax information.


Note the differences from other command interpreters in how the 32-bit Command Interpreter handles environment variables.


The SET command sets a new environment variable, displays an existing environment variable, or displays a list of all environment variables in the environment of the command interpreter process.

If no arguments are supplied, SET writes a list of all currently defined environment variables to its standard output, one per line, in the form "name=value". If an environment variable name is supplied, SET writes the value of that environment variable to standard output, in the form "name=value". If a name and a value are both specified, SET defines (or redefines) the environment variable with that name to have the given value.

Because of the syntax of the command, it is not possible to create an environment variable whose name contains an equals sign. The equals sign terminates the name, and the remainder of the command line is taken to be the value to assign to the variable. To create a variable whose name contains an equals sign, use the SETENV command, whose syntax allows this.

It is possible, however, to create an environment variable with an empty string for its value. This behaviour is different to that of the 16-bit CMD supplied with IBM OS/2, where attempting to set an environment variable to an empty string deletes it instead. To delete an environment variable, use the UNSETENV command.

A child process of the command interpreter inherits the command interpreter's environment as it was at the time that the child process was started. Further modifications to the command interpreter's environment will not affect the environment of the child. Neither will modifications to the environment of the child process affect the environment of the command interpreter.


The 32-bit Command Interpreter is © Copyright Jonathan de Boyne Pollard. "Moral" rights are asserted.