PATH: Instructional Server> Computer Basics>

Windows "Command Prompt" Utility


Computer novices are advised to read the web pages about Fundamentals of Computer Science and about Data Types & Languages before reading this document.

User Intefaces

Whenever two fundamentally different entities or devices have to interact, a device or procedure called an interface is developed to translate between the languages used by each. An interface which allows humans to interact with a computer system is called a user interface.

When it comes to communicating with a computer, try to remember that English is not its native tongue. Try thinking of the computer as a foreigner who does not speak English very well. A computer may be very competent at processing data, but you will have to adjust to its language limitations. This adjustment is not difficult. It just requires a little ingenuity and patience.

User interfaces come in a few basic types:

  1. Character-based User Interfaces (CUI's) require users to type commands one character at a time at a keyboard. When using these, we must learn and follow strict rules of syntax for each language. For example, in English we place the subject of a sentence in front of the verb. Before you can type commands on a computer, you must learn the rules of syntax for each program which you plan to use. Then you construct command lines (which are the computer equivalent of English sentences) to control your computer.
  2. Many programs are now written using the menu-driven approach. We control them by simply viewing a menu of command choices on the screen and pressing a letter or numeral to indicate the command which we would like to use. This approach to program control is much easier to learn and to use than the older command line approach in which we had to memorize and type complete words or lines of instruction. The disadvantage to menu driven programs is that they limit us to doing only those tasks which appear on the menu.
  3. The most popular interface nowadays is the graphic user interface (or GUI) which involves the display of small pictures (known as icons) or other graphic objects which serve as menu choices. We can now use pointing devices, such as the arrow keys on a keyboard or a hand-held mouse, to indicate desired choices. This is known as using the point-and-click approach.

All of these interfaces involve rules of syntax, even though some of them are not based on typing command lines. Eventually we will have to type a response to a question (or "prompt") or we will have to type out a detailed specification of something. So we will still have to know some rules of syntax. Even when using the point and click approach to controlling our computers, a user must occasionally revert to the older command line method of control. As large and versatile as it is, even Windows does not provide a menu choice or icon for every possible action that a user might want to perform when operating a computer. For this reason, Windows still provides the user with a character-based command line interpreter. This is a program that runs in a plain black and white window and interprets each individual line of command typed by the user. It looks similar to the illustration below.

C:\Documents and Settings\owner>_

This program is run from the Start button on the taskbar at the bottom of the Windows desktop as follows:

  1. Click on the Start button.
  2. Select the menu choice All Programs.
  3. When the sub-menu appears, slide sideways into it and then up to select the menu choice Accessories.
  4. When the next sub-menu appears, slide sideways into it and then down to select the menu choice Command Prompt.

That should open a window similar to the one above. The line in the illustration that reads "C:\Documents and Settings\owner>" might be different, as it is a system prompt message that reports the current working directory. The example above indicates that the current working directory is a storage folder on the C: disk drive. The part that reads "\Documents and Settings\owner>" describes a path through the hierarchy of storage folders, starting with the root or main folder (indicated by the first backwards slash character "\"), then looking in a sub-folder named "Documents and Settings" and finally in a sub-folder named after the current user of the computer, "owner". The ">" character is typically displayed by the command interpreter to indicate where it expects the user to type the next command. The underline character ("_") represents the flashing cursor, indicating where the user's next keystroke will appear.

You can command the interpreter to display a list of its most common command keywords by entering the command: help

You can get help on a specific command by entering the keyword help, followed by the specific keyword you want to know more about. For example, if you wanted help about the mkdir (Make Directory) command, you could type: help mkdir

In the command prompt window, the dialog would resemble:

C:\Documents and Settings\owner>help mkdir
Creates a directory.

MKDIR [drive:]path
MD [drive:]path

If Command Extensions are enabled MKDIR changes as follows:

MKDIR creates any intermediate directories in the path, if needed.
For example, assume \a does not exist then:

    mkdir \a\b\c\d

is the same as:

    mkdir \a
    chdir \a
    mkdir b
    chdir b
    mkdir c
    chdir c
    mkdir d

which is what you would have to type if extensions were disabled.

The notations used in describing the commands are as follows:

Notation Meaning of the notation when seen in a command example
UPPER Words shown in uppercase letters must be typed as shown for the command to work. You may use either upper or lower case. Windows is not normally case sensitive. Some software manuals denote these words in boldface rather than uppercase.
lower Words in lowercase (some manuals use italics instead) identify positions in a command where you are expected to supply necessary information.
 
  Example: ERASE file-spec
 
Because the keyword ERASE is shown in uppercase, you must type it to use this command. The parameter "file-spec" in lowercase means that you are expected to substitute your own file specification in that position in the command, rather than to actually type the phrase "file-spec".
[   ] Items shown in brackets are optional, and may be omitted if not desired. Beware that omission of a optional item will result in a default being used. In any case, do NOT type the brackets.
 
  Example: DIR [d:]
 
Because the keyword DIR is shown in uppercase, you must type it to use this command. The lowercase "d:" means that you are expected to substitute your own drive letter (such as "d:") in that position in the command. The brackets around the drive letter indicate that you could omit typing it. But if omitted, the current default drive will be used.
| A vertical bar (also known as a "pipe") indicates mutually exclusive choices on a line. It can be thought of as meaning either/or. It indicates that you should choose only one item from a list of items.
 
  Example: BREAK [ON|OFF]
 
The notation above means to type either BREAK ON or BREAK OFF, but not BREAK ON|OFF. Because the parameter is in brackets, you could also type just BREAK, and accept the default reaction from this command.
... An ellipsis indicates that you may repeat an item.
 
  Example: PRINT file-specification[ ...]
 
This means that you could provide more than one file specification in this command.

Be sure to include all punctuation (except the symbols above) exactly as indicated when entering a command.


Error Messages

If the interpreter program is unable to interpret a command or if it encounters a problem reading data because of coding errors or hardware problems, it will usually display an error message indicating the problem. These error messages are not always as clear and descriptive as we might hope because they require valuable storage space to be stored, and thus are kept as brief as possible.

The three most frequently received error messages are:

  1. Bad Command or Filename
     
    This means that Windows did not recognize an entry as a command, neither a keyword nor an executable program file from the disk. The most likely reason for this is that the command was typed incorrectly; a "typo", poor syntax, etc. This will also appear if you fail to identify the correct disk when trying to execute an external command.
     
  2. (type) (action) (device)
    Abort, Retry, Ignore, Fail?

     
    This message will appear for almost any error during a read or write process. The (type) "field" will be replaced by the type of error: "Not Ready", "Write Protect", etc. The (action) field will generally indicate either: "reading" or "writing". The (device) field will indicate the device on which the error occurred: "Drive A", "Printer", etc.
     
      Windows waits for you to respond by pressing either A,R,I, or F:
        A - Abort (stop attempting to perform the command)
        R - Retry after your attempts to correct the problem
        I - Ignore the error and continue executing the next step in the command or program
        F - Continue execution, but send a Fail notice to Windows
        When in doubt, press: A
        Press only the letter. Do not press the Enter Key.
     
  3. Invalid number of parameters
     
    This results whenever you provide too many or too few parameters following the keyword on a command line. The most common cause of this is when you incorrectly include or omit blank spaces.

Most Popular Command Prompt Commands

Keyword Description
CD or CHDIR Displays the name of or changes the current directory.
CLS Clears the screen.
COMP or FC Compares the contents of two files or sets of files.
COPY Copies one or more files to another location.
DATE Displays or sets the date.
DEL Deletes one or more files.
DIR Displays a list of files and subdirectories in a directory.
ECHO Displays messages, or turns command echoing on or off.
ERASE Deletes one or more files.
EXIT Quits the CMD.EXE program (command interpreter).
HELP Provides Help information for Windows commands.
LABEL Creates, changes, or deletes the volume label of a disk.
MD or MKDIR Creates a directory.
MORE Displays output one screen at a time.
MOVE Moves one or more files from one directory to another directory.
PATH Displays or sets a search path for executable files.
PAUSE Suspends processing of a batch file and displays a message.
PRINT Prints a text file.
PROMPT Changes the Windows command prompt.
RD Removes a directory.
REM Records comments (remarks) in batch files or CONFIG.SYS.
REN or RENAME Renames a file or files.
RMDIR Removes a directory.
TIME Displays or sets the system time.
TREE Graphically displays the directory structure of a drive or path.
TYPE Displays the contents of a text file.
VER Displays the Windows version.
VOL Displays a disk volume label and serial number.
XCOPY Copies files and directory trees.

For more information on a specific command, type HELP followed by the keyword or view the [MS-DOS and command line overview ] from [http://www.computerhope.com/].

PATH: Instructional Server> Computer Basics>