The Command Line
Everything you do in DOS is done from the command line.
The command line begins with a prompt, which is the computer’s
way of saying “I’m ready. Give me something to do.” The prompt usually
looks something like this:
But note that you can configure how your prompt appears, so you
should not assume it will always appear exactly like the example.
From the command line you can do two things: you can run an internal
command (one that is contained in COMMAND.COM), or you can run a program. External
commands are programs, which are found in separate files in your DOS directory,
so running programs includes running external commands, but it also means running
the applications software you use to do things with your computer. You can also
run a batch file, but in that case all you are doing is running a series of
commands or programs that are listed in the batch file. If you enter a name
that is not recognized by DOS as either an internal command or a program, you
get the error message “Bad command or file name” as a consequence.
The NT command interpreter gives an even more informative message: “The
name specified is not recognized as an internal or external command, operable
program or batch file.” If you receive an error message like this, it means
one of several things:
- The name you gave is incorrect for some reason. Possibly you misspelled
the name. Or maybe you are using the wrong name. Check the name and the
spelling and try again.
- Maybe the program you are trying to run is not installed on the computer.
Verify that it is installed.
- The file is there, but the computer does not know where to find it.
Executable application files
For DOS to run an application file , it has to be one of three
- COM – A file in machine language, must be less than 64K in size.
- EXE – A file in machine language, can be larger than 64K. EXE files also
have information at the beginning of the file that tells DOS what type of
file it is and how to load and run it.
- BAT – A batch file that is written with a text editor and
is in ASCII text format, it contains DOS commands that are executed in batch
mode, which means that each command is executed in sequence until the file
We mentioned above that sometimes DOS cannot find a valid file. That brings
us to the idea of a path. When you enter the name of an executable
application file, DOS has to find it. DOS looks for the file in a specific hierarchy
- The active directory of the current drive (called the working directory).
If you are in the directory C:\DOS, and you type in the name FOOBAR.EXE,
DOS will logically enough look in C:\DOS for such a file. In fact, you do
not need to type in the entire name. If you simply type in FOOBAR, DOS will
look for any executable file with that name, whether it is FOOBAR.EXE, FOOBAR.COM,
or FOOBAR.BAT. If DOS finds this file, it will run it.
- If DOS does not find this file, it will consult something called the PATH.
This is a list of directories that DOS has been instructed to check whenever
it cannot find a file in the current active directory.
You can see what the path is for your computer at any time by using the PATH
command. Just type “path” at the DOS prompt, and you will get back
your path. Here is what I got on one of my machines:
The first line is the prompt, and the command I typed, and the second line
is what the computer returned. You can see that the first place that DOS will
check is the Windows 3.1 directory, and the second place is the DOS directory.
If I wanted to change this, I could enter a path command and put in a new path:
Now, when I check my path, I get this:
BTW, I’m sure you noticed that some of these characters are lower case, and
some upper case. It really doesn’t matter, because DOS is not case sensitive.
Internally DOS uses all upper case letters, which is why you see the output
from your commands in upper case. But if you type them in as lower case, a converter
automatically converts them to upper case and then they are executed.
Now, try setting a path on your DOS test computer. Notice that whenever you
enter a PATH command it replaces whatever path was in the computer previously.
This is useful to know.
The next question you might have is where that first path came from. Well,
that is set in the AUTOEXEC.BAT. This is a batch file that automatically executes
(hence the name) when you boot your computer. You can edit this file with the
DOS program EDIT. To see or edit the contents of this file you need to enter
the following command:
After you have looked at this file, you can exit from the program by hitting
the following keys in order:
Now, what would happen if you removed C:\DOS from the path? You would suddenly
find that you could not use any external DOS commands unless C:\DOS is the working
directory! So having C:\DOS (or whatever your DOS directory is) in the path
is extremely important.
Path alterations and confusion
When you install software in DOS, it is common to find that the software you
installed has modified the AUTOEXEC.BAT and changed the PATH command it contains.
This is not necessarily a bad thing. Often the program needs this to function.
And it does make life convenient. As an example, one of the most popular DOS
programs was WordPerfect, the word processing program. This program would typically
install itself in the directory C:\WP, and then add this directory to the path.
The executable file to launch this program was WP.EXE, which would be found
in the C:\WP directory. By having this directory in the path, all you needed
to do to launch and run this program is type “wp” at any command prompt.
This is very convenient. But there are a couple of considerations in using the
path. First, the path has a limit of 256 characters total, so you cannot simply
add every directory on your hard drive. Second, DOS will search through every
directory in the path looking for an executable file. The more directories you
put in there, you the more searching that goes on. So you want to keep your
path statement limited to the essentials. This usually means your DOS directory,
a couple of frequently used apps, and the directories for drivers for peripherals
like the mouse and the sound card. For other programs, you can create simple
batch file, or even a menu, that will let let you switch the working directory
and launch the program in one step. We will cover this technique later.
One thing you need to watch out for is having two PATH commands in the AUTOEXEC.BAT.
This is not good because the second one will replace the first one. So you want
to make sure you only have one PATH command in your AUTOEXEC.BAT. But watch
out for something like this:
This looks like two PATH commands, but it isn’t. The first line is creating
a variable called “PATH”, and the second line, which
is a PATH command, is including the contents of the PATH variable. This is a
legitimate technique, and all three directories will be in the resulting path.
One last note on paths: DOS will go through each directory in the PATH statement
in order looking for the executable file you tried to run. You can improve your
DOS performance, therefore, by placing directories in the proper order. I would
always put the DOS directory first on a purely DOS system. (If you have Windows
3.1 installed you might to put that directory first, followed by the DOS directory.)
I would follow this with the device drivers, like the mouse and sound card,
and place an application directories at the end. And I would only include those
applications that I use on a daily basis in the path.
DOS Lesson 5: The Path by Kevin O'Brien is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.