Sideway
output.to from Sideway
Draft for Information Only

Content

MS DOS Command: SET
 Description
 Syntax
 Parameters
 Related Commands
 Remarks
  Displaying the current environment settings
  Using parameters
  Using SET in batch files
  Calling a SET variable from a batch file
  Effect of SET on environment space
  Using the COPYCMD environment variable
 Examples

MS DOS Command: SET

Reference from Microsoft MS-DOS cmd help

Description

Displays, sets, or removes MS-DOS environment variables.

You use environment variables to control the behavior of some batch files and programs and to control the way MS-DOS appears and works. The SET command is often used in the AUTOEXEC.BAT or CONFIG.SYS files to set environment variables each time you start MS-DOS.

Syntax

SET variable=[string]

To display the current environment settings, use the following syntax:

SET

Parameters

variable Specifies the variable you want to set or modify.
string Specifies the string you want to associate with the specified variable.

Related Commands

For information about setting environment variables that MS-DOS uses to control its own operations, see the PATH, PROMPT, SHELL, and DIR commands.

Remarks

Displaying the current environment settings

When you type the SET command alone, MS-DOS displays the current environment settings. These settings usually include the COMSPEC and PATH environment variables that MS-DOS uses to help find programs on disk. PROMPT, DIRCMD and COPYCMD are some other environment variables that MS-DOS uses. For more information about DIRCMD, see the DIR command.

Using parameters

When you use a SET command and specify values for both variable and string, MS-DOS adds the specified variable value to the environment and associates the string with that variable. If the variable already exists in the environment, the new string value replaces the old string value.

If you specify only a variable and an equal sign (without a string) for the SET command, MS-DOS clears the string value associated with the variable (as if the variable is not there at all).

Using SET in batch files

When creating batch files, you can use the SET command to create variables and use them in the same way as you would the numbered variables %0 through %9. You can also use the variables %0 through %9 as input for the SET command.

Calling a SET variable from a batch file

When you call a variable value from a batch file, you must enclose the value with percent signs (%). For example, if your batch program creates an environment variable named BAUD, you can use the string associated with BAUD as a replaceable parameter by inserting %BAUD% on the command line.

Effect of SET on environment space

After you use a SET command, MS-DOS might display the following message:

Out of environment space

This message means the available environment space is insufficient to hold the new variable definition. For information about how to increase the environment space, see the COMMAND command.

Using the COPYCMD environment variable

You can set the COPYCMD environment variable to specify whether you want the COPY, MOVE, and XCOPY commands to prompt you for confirmation before overwriting a file, whether issued from the command prompt or a batch file.

To force the COPY, MOVE, and XCOPY commands to prompt you before overwriting in all cases, set the COPYCMD environment variable to /-Y. To force these commands to overwrite in all cases without prompting you, set the COPYCMD environment variable to /Y.

Typing any of these commands with the /Y or /-Y switch overrides all defaults and the current setting of the COPYCMD environment variable.

Examples

To set an environment variable named INCLUDE so that the string C:\INC (the INC directory on drive C) is associated with it, type the following command:

set include=c:\inc

You can then use the string C:\INC in batch files by enclosing the name INCLUDE with percent signs (%). For example, you might include the following command in a batch file in order to display the contents of the directory associated with the INCLUDE environment variable:

dir %include%

When MS-DOS processes this command, the string C:\INC replaces %INCLUDE%.

Another possible use for the SET command is in a batch program that adds a new directory to the PATH environment variable, as the following example shows:

  • @echo off
  • rem ADDPATH.BAT adds a new directory
  • rem to the PATH environment variable.
  • set path=%1;%path%
  • set

©sideway

ID: 110700253 Last Updated: 7/30/2011 Revision: 0


Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Travel 18

Reference 79

Computer

Hardware 254

Software

Application 213

Digitization 37

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 431

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Set 1

Logic 1

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2025 Sideway . All rights reserved Disclaimers last modified on 06 September 2019