Smart Computing ® Smart Computing ®
Top Subscribe Today | Contact Us | Register Now   
middle
Home | Tech Support | Q&A Board | Article Search | Subscribe & Shop   


An Introduction To Autoexec.bat Email This
Print This
View My Personal Library

PC Operating Instructions
April 1994 • Vol.5 Issue 4
Add To My Personal Library

An Introduction To Autoexec.bat

Jump to first occurrence of: [AUTOEXEC.BAT]

It's one of those nebulous presences that lurks in the shadows of your system, going about its own obscure purposes with its own dubious designs. It's not quite as threatening as the shady CMOS nor as amicable as the DOS Shell, but many keep a wary distance—just in case. After all, it does have a reputation as a batch file.

Your system's Autoexec.bat doesn't do much to assert its presence—you probably don't see it much except for an occasional meeting during the installation of a program when you are asked if the setup program should update your Autoexec.bat file. Apprehensively, most of us let the program do the talking and continue to keep our distance.

While the don't -bother- it-and-it-won't-bother- you rule generally holds true for this file, Autoexec.bat is a file with connections. Dealing with it just right can get you better cooperation with memory, hook you up with the right programs, and get you some choice DOS prompts, to name a few things.

But before you can start negotiations, you need to meet the file one on one. So relax a little and come on down to your system's DOS basement for an introduction. Oh, and . . . don't make any sudden moves.



First Impressions



Autoexec.bat is an automatically executing batch file—a file containing operating system commands that run each time you start or restart your computer. The commands inside your system's Autoexec.bat file essentially define or configure the way that system components such as hard disks, keyboards and peripheral devices (like printers) will work with your system.

The colors that appear on your screen, the port your printer is connected to, and the text that appears at the DOS prompt are a few examples of things that you can control by specifying commands in your Autoexec.bat file.

One other helpful thing Autoexec.bat can do is launch (start) programs and load memory resident (TSR—terminate-and- stay-resident) programs into memory. A TSR is a program that stays loaded in memory even when it isn't currently running so that it can be quickly and easily used when needed.

Most systems purchased today come with the Autoexec.bat file already created by DOS when it is installed. (With earlier versions of DOS, users had to create their own Autoexec.bat files.) You can tell if your system has an Autoexec.bat file by watching it boot up. Systems without an Autoexec.bat file will prompt for date and time when they start up (though systems with Autoexec.bat files containing the DATE and TIME commands will, too).

There are a few commands that are pretty standard for an Autoexec.bat file to contain. These include: ECHO, DATE, TIME, PROMPT, PATH, MODE, SET, LH, CLS. (For a sample Autoexec.bat file, see Figure 1.) To look at the contents of your Autoexec.bat file, type type autoexec.bat and press ENTER at the DOS C> prompt.

Now let's take a look at these commands and just how they might be used in an Autoexec.bat file.



ECHO



The ECHO command is used to turn command "echoing" on or off. If the echo is on, the Autoexec.bat file commands will appear on-screen at the DOS prompt as DOS receives them for execution, followed by a blank line. Turning the echo off basically eliminates this screen clutter.

The command to turn the echo off (it is on by default) is: ECHO OFF. To turn the echo back on, the command would be: ECHO ON. The echo command usually goes at the beginning of the Autoexec.bat file.



DATE



Including the DATE command in the Autoexec.bat file will display the system date and gives you a chance to change it. To use the DATE command DATE must be included on a line inside your Autoexec.bat file.



TIME



The time command works a lot like the DATE command. If TIME is specified on a line inside your Autoexec.bat file, your system will prompt you for the current time when it starts. DOS includes the current time when changes are made to files during tasks such as backing up and restoring information to your hard drive.

Depending on your system, the new time setting might be effective for only the current session and need to be reset the next time the computer is started.



PROMPT



The PROMPT command can be used to customize your DOS prompt. (This is the perfect way to startle your office mates who may not be quite so familiar with the Autoexec.bat file.)

The PROMPT command alone in your Autoexec.bat file will display the current drive and directory. Adding specific codes after the PROMPT command can alter your DOS prompt to include the current path, the greater-than sign, a blank line, the time or the date. (For more on the PROMPT command, see the sidebar, entitled, "Prompting For More.")



PATH



The PATH command specifies a search path for DOS, telling it where to look to find the program files that run your DOS programs. A program entered in your path will start at the proper command without your having to change to the program directory first. Paths are defined by including the PATH command line in your Autoexec.bat file, followed by the specific search path.

Without a defined path in the Autoexec.bat file, DOS searches the current directory only. If the program file needed to start the program you have given the command for is not found, then DOS displays an error message.

When you install new DOS programs, you often do not need to manually update your path as the install program usually offers to update your Autoexec.bat for you.

To see your current path, simply enter path at the DOS prompt and press ENTER.



MODE



The MODE command is used to configure system devices, like printers and modems and your keyboard. It can also be used to display device status and alter things like ports.

Identifying the command in your Autoexec.bat file is easy—you will see the MODE command at the beginning of the command line, followed by configuration specifications. Actually using the MODE command is a bit more complicated than some of the other commands you might find in the Autoexec.bat file. For more information on the MODE command, consult your DOS manual or DOS help (by entering help and pressing ENTER at the DOS prompt).



SET



SET is a command that is used to set or change values or environments. Chances are, if SET is used in your Autoexec.bat file, it might be adding a directory to the end of the path you currently have or be setting the value of a temporary storage place for files to a specific directory location.

Used alone, SET displays the current values of environmental variables so that when you start your computer, things like the current PATH settings will appear onscreen.



LH



nH is short for the LOADHIGH command, which loads programs into upper memory (an area in the 384KB of memory after the first 640KB of conventional memory) instead of conventional memory (which DOS uses to run programs). Loading programs high is important for keeping as much conventional memory available as possible, since without enough available conventional, DOS cannot run certain programs. (Note: you need to have a 386 or faster system in order to be able to load programs high.)

If you are running version 6 or 6.2 of DOS, using the LH command is as simple as running the memmaker program (a program included with DOS for optimizing memory use). Memmaker automatically inserts the necessary LH commands into Autoexec.bat for you (which usually goes in front of the command to launch TSRs or other programs that are placed in the Autoexec.bat to launch automatically).

For more on the LH command or how to use it manually (in the case of an earlier version of DOS), see your DOS manual or consult DOS help.



CLS



CLS is a nifty command that clears your screen. Typed at the DOS prompt, it gets rid of the onscreen clutter. Placed at the end of your Autoexec.bat file, CLS clears away all the things that appear on your screen during startup so that when your system is finished executing startup commands, you have a fresh new screen to begin with. This command is more a matter of personal preference than it is a technical tweaker.



A Little Light



You might not call Autoexec.bat the friendliest face you've seen, but perhaps this file's inner workings won't be quite so shady as before. And while you might be a little wary yet, Autoexec.bat offers a few commands you just might not be able to refuse.

by Tosca Moon Lee


Backing Up Your Autoexec.bat


When you're ready to add a command to your Autoexec.bat or just fine tune something that's already in there, you'll find that editing is easy.

But before you make changes to your file, take a minute to make a quick backup of your original as a safeguard. With a backup copy on hand, you will always be able to refer back to your original Autoexec.bat should you accidentally delete a line you realize later that you needed, forget what was there before, or just decide that you liked it better the first way.

To copy your Autoexec.bat from your hard disk onto a diskette:

1)Insert the diskette into drive A:.

2)Make sure that you are currently in the root directory (the main directory) of your hard disk.

3) Type copy autoexec.bat a: at the DOS prompt. This command copies the Autoexec.bat file to the diskette in drive A:.

Now, in order to edit your Autoexec.bat file, simply type edit autoexec.bat at the DOS prompt (from the root directory of your hard drive). You can go in and edit the lines much as you would any text file. When you are finished, be sure to save your changes (choose ALT to activate the menu bar and choose Save from the File menu). To exit after saving, choose Exit from the File menu.



Your changes will take effect when you reboot your system.




Prompting For More


While the PROMPT command alone displays the current drive and the directory, there is much, much more fun to be had with this command. For instance, adding $p after the PROMPT command in your Autoexec.bat file will display both the current drive and the path, and $g after the PROMPT command will display the greater-than (>) sign.

More prompt codes follow:



$T Current time

$D Current date

$V DOS version number

$N Current drive

$L Less-than sign (<)

$B Pipe sign (|)



You can also use text with the PROMPT command—making it entirely possible for your computer to greet you in the morning with a cheerful welcome such as, "good morning!" Just enter the text to appear with your new prompt after the command.

For additions to your Autoexec.bat file to take place, be sure and save your changes and reboot your system.






Want more information about a topic you found of interest while reading this article? Type a word or phrase that identifies the topic and click "Search" to find relevant articles from within our editorial database.

Enter A Subject (key words or a phrase):
ALL Words (‘digital’ AND ‘photography’)
ANY Words (‘digital’ OR ‘photography’)
Exact Match ('digital photography'- all words MUST appear together)





Home     Copyright & Legal Information     Privacy Policy     Site Map     Contact Us

Copyright © 2010 Sandhills Publishing Company U.S.A. All rights reserved.