Professional Documents
Culture Documents
Page 1 of 13
file://J:\Que\chapters\JW349.html
9/12/2001
Page 2 of 13
z DOS requires that you use a specific set of rules, or syntax, when you issue commands.
z All DOS commands begin with a keyword that identifies the action you want performed.
z Parameters, which are a part of a commands syntax, refine the way a command is executed.
Syntax is the order in which you type the elements of the DOS commandits grammar. If you say,
"Ball red the choose I," people probably will not understand that you are trying to say, "I choose the red
ball." Some people might understand what you are trying to say, but not many. A computer, on the other
hand, has no intelligence or imagination; it can interpret commands only according to its programming.
Programming several optional syntaxes for commands requires using a great deal of extra memory and
disk space, which cuts down on the resources available to do real work. That's why you have to supply
the intelligence and imagination and why you must enter DOS commands precisely according to the
rules of command syntax.
You can think of the command keyword as the action part, or verb, of a DOS command. In addition to
the keyword, many commands require or allow further directions. You supply these directions as
parameters and switches. Parameters tell DOS what action to take or how to apply the action. Using
DOS commands is easy as long as you follow the rules of order and use the correct parameters. After
you know the basic rules, you often can figure out parameters for commands that you don't use on a
regular basis.
Most applications software incorporates the issuing of commands as part of the software's operation.
The commands discussed in this book are DOS commands. Be sure that you know the difference
between DOS commands, which you issue at the DOS command line, and the commands you learn to
use with your applications software.
If you are unsure whether a command you have been taught to use is part of DOS, look in Appendix F,
"Command Reference." If that command is not listed, it is an application program command, not a DOS
command.
A DOS command always begins with the keyword, which is the name of the command, followed by a
space. If you use the language metaphor, the keyword is the verb that specifies the action to be taken.
The first example shows the common form for DOS commands that don't change files in some way. The
file://J:\Que\chapters\JW349.html
9/12/2001
Page 3 of 13
Drive\Files portion of the example is a parameter that specifies what drive or files on which the
command is supposed to act. This parameter is analogous to a noun in English. In other words, the
parameter is the thing on which the verb acts. This portion of the syntax is in italic to show that the
parameter is optional. The parameter also can be followed by command-line switches. To extend the
language metaphor, switches are like adverbs; they modify the verb. They change the action to be done.
The second example here is typical of the syntax for most DOS commands that operate on groups of
files. The keyword, of course, specifies the action, followed by two parameters that indicate the disk or
files that provide the data source for the action. The second parameter indicates the target disk or files.
To copy a group of files from one disk or directory to another, for example, you can use the following
command:
COPY A:Myfile.TXT B:Yourfile.TXT
This command copies a file having the name MYFILE.TXT on drive A into the memory of your computer
and then writes the contents of the file onto drive B using the name YOURFILE.TXT.
Note - Some parameters or switches are optional, meaning that some parts of the command
syntax, such as the keyword, are mandatory. When you enter only the mandatory command
elements, DOS (in most cases) uses default parameters for other elements.
A good example is the COPY command. If the following is the command, the default target
the currently logged disk and directory:
COPY A:MyFile.TXT
If youre in C:\TEMP, the file is copied to that directory, and the current filename,
MYFILE.TXT, is the target filename as well.
As you can see, having defaults makes commands easier to use and shorter, and gives you
fewer opportunities to make mistakes.
Because many DOS commands have several parameters, switches, and defaults, different forms of these
commands might be correct. You seldom, if ever, use all the optional syntax for any command. Some
switches actually are mutually exclusive. You cannot format a floppy disk as both high density and low
density, for example.
To find out what options are available for any given command, you should look up the command in the
"Command Reference" later in this book. The first time you look up a complex command, dont let the
sheer volume of optional parameters and switches throw you for a loop. Even the simplest of DOS
commands has several options.
The way the syntax is presented often is called the paradigm. Even the simple DOS commands have an
imposing paradigm. A good example is the DIR command, a real workhorse of a command. Its paradigm
looks something like the following:
file://J:\Que\chapters\JW349.html
9/12/2001
Page 4 of 13
You use the DIR command to display a directory of one or more files stored on a disk. This command
might look formidable, but it is much easier to understand if you break down the individual components.
For a description of the DIR command and its options, see "Listing Files with the DIR Command" in
Chapter 8, "Managing Your Files", p. 193.
Dont be confused by this formal rendering of the filespec; it simply states that the filespec can contain a
drive letter, a pathname, a filename, and an extension.
Note - Many new users are confused about the way slashes and backslashes are used in
commands. In actuality, their uses are stated simply in two rules:
z Backslashes (\) are used as separators (delimiters) when specifying directory and file
information.
z Slashes (/), sometimes called forward slashes, are used as signals to DOS that the
9/12/2001
Page 5 of 13
switch parameters to the switch by using a colon (:), as in the following example:
FORMAT A: /F:360 /S
In this example, the /F switch specifies that a 360KB floppy disk be formatted in a disk drive that
normally uses high-density (1.2MB) disks.
Getting Help
These days, the manuals supplied with DOS dont provide all the information they did in previous
versions. They no longer contain a complete printed reference for all the DOS commands. To get the
official Microsoft syntax for every DOS command, you have to pony up extra dollars to buy the MSDOS Technical Reference. Because you already have this book, you probably dont want or need the
Technical Reference. Appendix F, "Command Reference," contains a wealth of information about
undocumented switches and parameters.
In place of the printed manual that used to come with DOS, Microsoft has opted instead to supply an
online command reference. It falls short of the reference in the back of this book, of course, because it
doesnt include the undocumented information; but most of the time, you will find the online reference
to be adequate and handy.
To access online help for the use of a particular command, use one of the following procedures from the
DOS prompt:
z Type the DOS command, followed by the switch /?.
z Type HELP, followed by the DOS command.
file://J:\Que\chapters\JW349.html
9/12/2001
Page 6 of 13
DOS displays the command summary help screen shown in Figure 3.1.
Figure 3.1
Using the DOS command summary help.
forward one line. To move backward, click the upward-pointing scroll arrow.
z Press the Ctrl+down arrow key combination to move forward; press the Ctrl+up arrow key
file://J:\Que\chapters\JW349.html
9/12/2001
Page 7 of 13
move backward.
z Press the PgDn key to move forward one whole screen; press the PgUp key to move backward.
In Figure 3.2, notice the words Notes and Examples near the top-left corner of the screen. Each word is
enclosed within solid, triangular characters. Each of these specially marked words is a jump. A jump
provides a link to additional information on the currently selected topic or to related topics.
Jumps in the body of the help systems text are marked with angle brackets (<>). The brackets are
colored to help you more easily see them if your video card and monitor support color. Although not
shown in Figure 3.2, the word <TREE> at the end of the DIR help text is another example of a jump.
When you select a jump, the online help system displays the text related to the topic named by the jump
word. To select a jump, use one of the following methods:
z Click the jump with the mouse.
z Move the cursor over the jump and then press Enter.
If you select the <Examples> jump shown in Figure 3.2, the help system displays a screen containing
examples of the DIR command and explanations of each example. Selecting a jump such as <TREE>
causes the help system to display the help for the TREE command.
In Figure 3.2, the solid bar across the top of the screen with the words File and Search is the help
systems menu bar. You use the help systems pull-down menus in the same way you use the pull-down
menus in the DOS Shell.
If you are unfamiliar with using pull-down menus, see Chapter 4, "Using the DOS Shell," p. 57.
The choices on the File menu enable you to print a topic or exit the online help system. The choices on
the Search menu enable you to search for a topic, word, or phrase and repeat the last search.
Another solid bar appears at the bottom of the screen (refer again to Figure 3.2). The bottom-right corner
of this area of the help screen displays numbers indicating the current line and column number of the
cursor. In Figure 3.2, the cursor is at line 1, column 2 of the help text for the DIR command.
At the left edge of this area, three keystroke combinations and their functions are displayed:
<Alt+C=Contents> <Alt+N=Next> <Alt+B=Back>
Each label enclosed in brackets also doubles as a command button if you have a mouse. You can click
the command button or press the key command, Alt+C, causes the online help system to display its table
of contents. Each item in the table of contents is a jump. The Next command, Alt+N, causes the online
help system to display the next topic. The Back command, Alt+B, causes the online help system to
file://J:\Que\chapters\JW349.html
9/12/2001
Page 8 of 13
Action
Alt
Alt+B
Alt+C
Alt+F
Alt+S
Alt+N
Ctrl+down
arrow
Ctrl+End
Enter
Esc
F1
F3
AZ
Shift+letter
PgUp
PgDn
Shift+Ctrl+F1
Tab
Shift+Tab
Printing a Topic
The online help system enables you to print the text for the currently displayed topic. You may
optionally send the output to a file on your disk instead of to the printer. The Print command is located
on the File menu.
When the help system displays the File menu, click the Print command. The help system opens the Print
dialog box shown in Figure 3.3.
file://J:\Que\chapters\JW349.html
9/12/2001
Page 9 of 13
For information on using dialog boxes, option buttons, text boxes, and command buttons, see Chapter
4, "Using the DOS Shell," p. 57.
Figure 3.3
The online help systems Print dialog box.
To print the current topic on your printer, simply press Enter or click the OK command button. To send
the text for the current topic to a disk file, select the File option button; then, in the text box, enter the
name of the file to which you want to send the output. Finally, press Enter or click the OK command
button.
Searching for a Topic
You use the Find command to search for a specific topic, word, or phrase. The Find command is located
on the Search menu.
When the help system opens the Find dialog box, you see a screen similar to the one shown in Figure
3.4.
Figure 3.4
The online help systems Find dialog box.
When the Find dialog box first opens, the Find What text box contains the word that the cursor was on
when you selected the Find command. In Figure 3.4, the cursor was on the word Notes when the Find
command was selected, so the Find What text box con-tains the word Notes.
Enter the topic, word, or phrase that you want to search for in the Find What text box, or use the word
already in the text box. Then, select which of the two Find options you want to use. You can use one,
both, or neither of these options.
If you check the Match Upper/Lowercase option check box, the search is case sensitive. If you check the
Whole Word option check box, it is assumed that you are searching for a whole word; partial word
matches will be ignored.
You can repeat any search by selecting the Repeat Last Find command on the Search menu or by
pressing F3.
Exiting the Help System
To exit the online help system using the mouse, pull down the File menu and click Exit. To exit the help
system using the keyboard, press Alt+F, followed by X.
file://J:\Que\chapters\JW349.html
9/12/2001
Page 10 of 13
DIR /P
When you issue the DIR command to see the files on a disk, the currently logged directory is used unless
you specify otherwise. Also, all the files in the directory are shown unless you somehow override the
default by explicitly specifying a file or group of files. By default, the display of files scrolls to the end
without stopping. In the preceding example, the display of all files in the current directory (the default)
is used, but the /P switch, which makes the listing pause after each page of filenames, overrides the
default behavior of scrolling to the end of the list without stopping.
Figure 3.5 breaks down the different elements that make up the DIR command. As you can see, only two
of the switches (/P and /W) are illustrated.
Figure 3.5
The syntax of the DIR command.
Figure 3.6 is a diagram of the DIR command as you might use it. If you are unfamiliar with the anatomy
of a command, the following sections explain each of the different parts.
Figure 3.6
Issuing the DIR command.
Action
Tab
file://J:\Que\chapters\JW349.html
9/12/2001
Esc
Cancels the current line and does not change the last command
buffer
Ins
Del
F1 or right
arrow
Copies the next single character from the last command buffer
F2
Copies all characters from the last command buffer up to, but not
including, the next character you type
F3
F4
F5
Moves the current line into the buffer but does not allow DOS to
execute the line
F6
Page 11 of 13
These editing keystrokes come from the earliest versions of DOS. Beginning with version 5.0, there is a
better way. The DOSKEY command, usually entered via AUTOEXEC.BAT, loads into memory a program
that creates a much larger buffer to store previous command lines. (Refer to the "Command Reference"
for the DOSKEY listing.) You can recall these commands by pressing the up-arrow key. The DOSKEY
buffer is 512 bytes by default, which is enough on average to store the last 20 commands executed.
For a complete reference source for DOS editing keystrokes, see Appendix D, "DOS and DOS Utility
Programs Keyboard Commands," p. 563.
file://J:\Que\chapters\JW349.html
9/12/2001
Page 12 of 13
Also, only those files bearing the extension .TXT match and are listed. Thus, LTR.TXT, LTR0.TXT,
LTR01.TXT, LTR001.TXT, LTRMOM.TXT, LTR_32.TXT, and LTR999.TXT are listed, but LTRPOPS.TXT or
LTR1001.TXT are not.
The * represents any string of characters. For example, *.* represents all filenames with any extension,
the default scope of the DIR command. The following command lists all files in the currently logged
directory having the extension .DOC:
DIR *.DOC
The following command lists all the files listed by the DIR LTR???.TXT example, as well as filenames
not matched by that form of the command:
DIR LTR*.TXT
You should look out for one thing when youre using the * wildcard, however. The following command
does not produce the result you might expect:
DIR *LTR.TXT
This example does not list all the .TXT files whose names end in LTR. Rather, it lists all the files having
the extension .TXT. The reason is deceptively simple. Because the * can represent up to eight characters
in a filename, any string of characters matches *LTR.
After you get the hang of using wildcards to refine the scope of command parameters that supply
filenames, you will find that you are well on your way to becoming a DOS power user.
Troubleshooting
My program wont run from the C:\ prompt!
When you install DOS on your system, by default, the program files for external commands are written
to a directory named DOS on the drive letter that your computer boots from. Because most systems boot
from drive C, most of the time youll find that the DOS directory is called C:\DOS.
If you look into the AUTOEXEC.BAT file, youll probably find a command line that begins with PATH,
followed by a list of directories. This command tells DOS where to search for program files when it is
trying to run a command. If your DOS directory is listed in the PATH command line, COMMAND.COM can
find the program files for external commands no matter what disk drive or directory you are logged on
to. A PATH statement looks like this:
Path=c:\; c:\DOS; c:\windows
If you install a program to a new directory without adding that directory to the PATH statement, that
program will run only if you change directories to where it resides. When you add the programs home
file://J:\Que\chapters\JW349.html
9/12/2001
Page 13 of 13
directory to the PATH statement, you can execute any file in that directory, no matter what directory you
are currently in.
file://J:\Que\chapters\JW349.html
9/12/2001