Indiana University
University Information Technology Services
  
What are archived documents?

In DOS, what is an AUTOEXEC.BAT file?

An AUTOEXEC.BAT file contains DOS commands that are executed automatically when a PC boots. The file is usually located in the root directory of the hard drive or floppy from which the computer boots up. The AUTOEXEC.BAT file is used to set defaults and to run programs that should be executed upon startup (comparable to the .login file on Unix accounts). Below is a list of statements that typically go into an AUTOEXEC.BAT file, followed by explanations of each statement's purpose.

The AUTOEXEC.BAT file is an example of a batch file, used to automate functions in DOS. In their simplest form, batch files contain DOS commands. There is, however, a batch file language that includes commands for such things as loops and execution branches.

ECHO

Example:

@ECHO OFF

This optional command will suppress the display of subsequent commands while the AUTOEXEC.BAT file is being executed. You can also use ECHO to display lines of text.

PATH

Example:

PATH C:\;C:\DOS;C:\WINDOWS;C:\TWSKPPP\LWP\BIN; C:\TWSKPPP\TWSK21F

Note: This example PATH command should actually be placed on a single line in the AUTOEXEC.BAT file, with the line wrapping around rather than being interrupted by carriage returns.

Sometimes, you will see the command in the form SET PATH, or PATH = . Both are valid forms of the command.

Use the PATH command to tell DOS which directories to look into when an executable file is not in the current directory. When you enter a line of text at the DOS prompt that is neither a recognized command nor an executable filename in the current directory, DOS will search through the directories in your PATH for a filename that matches the text you entered. This command is highly recommended unless you are using a menuing shell. Many packages (such as WordPerfect) automatically add or modify the PATH line during the installation process. The path cannot exceed 127 characters, and may be further limited by your DOS environment space.

Sometimes you might see more than one PATH command in AUTOEXEC.BAT. The second and subsequent PATH commands might have the form:

PATH=%PATH%;C:\BLASTER

%PATH% represents the existing path. This example would add C:\BLASTER to the path.

If you enter PATH at the C:\ prompt, the current path will be displayed. This can be a good troubleshooting tool, as it can tell you if the PATH command in AUTOEXEC.BAT has become too long and thus truncated.

SET

Example:

SET TRM=C:\WINDOWS\TEMP SET TEMP=C:\WINDOWS\TEMP SET BLASTER=A220 I5 D1 T1

SET is used to set system variables, which are used to pass information to programs. In these examples, the command is used to tell programs in what directories to store certain files or where configuration files are kept. Some programs (such as Windows) will set up this statement during the installation process, and many programs require SET statement entries in the AUTOEXEC.BAT file to run correctly. In some cases, a backslash following the end of a directory name is required, and spaces at the end of a line may cause trouble. If you enter SET at the C:\ prompt, all the system variables will be displayed.

PROMPT

Example:

PROMPT $P$G

Use the PROMPT command to alter the default DOS prompt. This particular example makes the DOS prompt display the current path and drive, and is very useful.

CLS

Example:

CLS CLS clears the screen.

Note: You should create or edit a DOS text file with only a DOS editor such as EDIT, EDLIN, or TED. If you use a word processing program, make absolutely sure that you save the file in text (ASCII) format, rather than any special file format that the word processor normally uses.

Also see:

This is document aaml in domain all.
Last modified on June 07, 2006.
Please tell us, did you find the answer to your question?