Command: set (command.com command)

  SET displays, sets, or removes ENVIRONMENT VARIABLE.
  SET is a BATCH-FILE / AUTOEXEC.BAT / FDAUTO.BAT command.
  It can also be used in command line.

Syntax:

  SET [/C] [/I] [/P] [/E] [/U] [variable[=[string]]]
  SET [/?]
  variable  Specifies the ENVIRONMENT VARIABLE name.
  string    Specifies a series of characters to assign to the variable.
  * If no string is specified, the variable is removed from the
    ENVIRONMENT.
  Type SET without parameters to display the current environment
  variables. Type SET VAR to display the value of VAR.

Options:

  /C  Forces to keep the exact case of the letters of the variable name;
      by default all letters are uppercased to keep compatibly.
  /I: has been temporarily included to the SET command to allow an easy
      way to display the current size of the ENVIRONMENT segment, because
      it is one of the most frequently reported, but not reproduceable
      bug report. Once this option has been encountered, all the
      remaining command line is ignored.
  /P: Prompts the user with the specified "string" and assigns the user's
      input to the variable. If no input is made, hence, one taps just
      ENTER, an empty value is assigned to the variable, which is then
      removed from the ENVIRONMENT.
  /E  Sets the given variable to the first line of output of the
      command pointed to by [string].
  /U  Changes the case of [string] to uppercase.
  /?  Shows the help.

Comments:

  The variant without any argument displays all the currently defined
  ENVIRONMENT VARIABLES in the format (without any whitespaces before
  or after the equal sign): name '=' "value"
  The variant "set variable=string" assigns a new value "string" to the
  specified variable. If the variable already exists, the old value is
  OVERWRITTEN WITHOUT NOTICE; otherwise it is newly created.
  Please keep this in mind as it may cause confusion!
  The command "set variable=" should be put before and after the last
  execution of "set variable=string" in a batch file to avoid wrong
  values for "variable" in another bad written batch file.
  SET can also be used outside a batch file. Please keep in mind that
  these are forgotten as soon as you shut down the machine!
  SET is a command internal to command.com and needs no other file
  in order to work.
  ENVIRONMENT VARIABLES are very helpful. As soon as they are set, you
  can use them instead of very long paths / text, e.g.:
  set DRV=C:\FREEDOS\BIN
  You can then enter defrag c: instead of C:\FREEDOS\BIN\defrag c: OR:
  edit: instead of C:\FREEDOS\BIN\edit etc - and this with one command
  line in AUTOEXEC.BAT / FDAUTO.BAT!

Examples:

  IN A .BAT FILE / AUTOEXEC.BAT:
    set            Displays a list of the current environment variables.
    set DRIVE=Z:\  Sets the environment variable DRIVE to the given
                   value "Z:\".
    set DRIVE      Shows the value of variable "DRIVE" (Z:\)
    %DRIVE%xy.bat (or xy.exe) executes the command
                   Z:\xy.bat or Z:\xy.exe.
                   Means: %DRIVE&percnt represents the value
                   "Z:\" in this case.
    set DRIVE=C:\  Changes from Z:\ to C:\. Z:\ will be FORGOTTEN!
    set DRIVE=     Removes the variable DRIVE from the environment so
                   that "DRIVE" and "C:\" are forgotten too.

See also:

  autoexec.bat/fdauto.bat
  batch files
  command.com/freecom
  config.sys/fdconfig.sys
  environment variable
  set (config.sys command)

  Copyright © 2004 Robert Platt, updated 2011 and 2022 by W. Spiegl.

  This file is derived from the FreeDOS Spec Command HOWTO.
  See the file H2Cpying for copying conditions.