Page 103 - 500
P. 103
The Command Combination Symbols
Unlike MS-DOS, Windows 2000 allows you to enter multiple
commands on a single command line. Furthermore, you can make
later commands depend on the results of earlier commands. This
feature can be particularly useful in batch programs and Doskey
macros, but you might also find it convenient at the command
prompt.
To simply combine commands without regard to their results, use
the & symbol, like this:
copy a :f1le.dat & edit f1le.dat
But what if there is no File.dat on drive A? Then it can't be copied
to the current drive, and the Edit command will fail when it can't
find the file. Your screen will be littered with error messages.
Windows 2000 provides two command symbols for better control
over situations like this:
• The && symbol causes the second command to run only if the
first command succeeds.
• The | | symbol causes the second command to run only if the
first command fails.
Consider this modified version of the earlier example:
copy a:file.dat && edit file.dat
With this command line, if the Copy command fails, the Edit
command is ignored.
Sometimes you want the opposite effect: execute the second
command only if the first fails. You can do this with the | |
symbol:
copy a:file.dat | | copy b:file.dat
This command line tries to copy the file from drive A. If that
doesn't work, it tries to copy the file from drive B.
The Escape Symbol
Some command symbols are legal characters in file names. This
leads to ambiguities. You can resolve such ambiguities by using
the caret (^) as an escape to indicate that whatever follows it is a
character rather than a command symbol.
Consider the following command line: