How to use an MS-DOS Command Prompt window  
Home > Tutorials > How to use an MS-DOS Command Prompt window

Note: This page has been superceded by the new How to Use DOS tutorial.

How to use an MS-DOS Command Prompt window


The following tutorial is meant as a very brief introduction to the MS-DOS Command Prompt window.

More detailed tutorials can be found online at other websites, such as at:

How to Use DOS blog.

Some of our scripts (such as DySE::Calendars) can be run on your Windows PC. If you plan on doing that, then you must know how to use an MS-DOS Command Prompt window and you will need to install ActivePerl on your Windows PC. For our other scripts (such as Associate Engine ae.pl), you might need to use an MS-DOS Command Prompt window to edit or view some files.


  1. Let's open an MS-DOS Command Prompt window. To do that, click on the "Start" menu (at the lower left of your screen) and select "Run...".

    If you are using Windows XP, then type "cmd" (no quotation marks) into the box and click "OK"; otherwise, type "command" (no quotation marks) into the box and click "OK".

  2. You should see an MS-DOS Command Prompt window appear.

  3. You tell the MS-DOS Command Prompt window what you want to do by typing commands rather than using your mouse. The MS-DOS Command Prompt window understands the commands described in the table below (there are more commands than those listed below). At the end of each command, press the Enter key. To get help on a particular command, add " /?" to the end of the command, such as: "dir /?".

For more details about DOS commands, see the How to Use DOS blog.

Command Meaning

cls

Clears the MS-DOS Command Prompt window and moves the command prompt to the top of the window (no files are changed -- the window display is merely cleared).

cd DIRNAME

MS-DOS works on one directory at a time. The "current" directory is indicated as part of the command prompt. For example, "C:\WINDOWS\Desktop>" means that the current directory is the "Desktop" directory which is located inside the "WINDOWS" directory. Use the "cd" command to make a different directory the "current" directory ("cd" is short for "change directory"). For example, "cd \perl" will make "\perl" the current directory. To get to the "root" of your c: drive, type "cd \".

dir
dir DIRNAME

"dir" lists the contents of the current directory. "dir DIRNAME" lists the contents of the DIRNAME directory, e.g.: "dir \perl" or "dir mystuff". If you add " /p" to the end of the command, such as "dir mystuff /p", then the output will pause after each screenful and wait for you to press any key (e.g.: Enter key).

notepad FILENAME

Starts the Notepad text editor program and opens the file named FILENAME. If the file does not exist, Notepad will ask you if you want to create a new file with that name. For example, "notepad ae-ini.txt" starts Notepad and opens the file ae-ini.txt located in the current directory. If you want to edit a file that is in a directory other than the current directory, then use the "cd" command first or include the directory name, such as: "notepad \www\ae\ae-ini.txt".

type FILENAME

Displays on the screen the contents of the file named FILENAME. For example, "type ae-key.txt" displays the contents of the file ae-key.txt located in the current directory. If you want to display a file that is in a directory other than the current directory, then use the "cd" command first or include the directory name, such as: "type \www\ae\ae-key.txt". Note: If the contents of the file is more than one screenful, then you should use the "more" command instead otherwise the text will scroll off the top of the window.

more FILENAME

Displays on the screen the contents of the file named FILENAME. For example, "more ae-ini.txt" displays the contents of the file ae-ini.txt located in the current directory. If you want to display a file that is in a directory other than the current directory, then use the "cd" command first or include the directory name, such as: "more \www\ae\ae-ini.txt". Note: If the contents of the file is more than one screenful, then "-- More --" will appear after each screenful and your computer will wait for you to press the Enter key to continue or press q (or Ctrl-C) to quit.

start .

The command "start ." (the . period is required, and there must be a space before it) causes the current directory to be shown in a Windows folder window.

copy NAME1 NAME2

Copy the file that has name NAME1 to NAME2. The file NAME1 is unchanged. If a file with the name NAME2 already exists, you will be asked if you want to overwrite the current NAME2 file. For example, "copy ae-ini.txt ae-backup.txt" copies ae-ini.txt to ae-backup.txt.

ren NAME1 NAME2

Rename the file that has name NAME1 to NAME2. If NAME2 already exists, then an error message is shown instead. For example, "ren ae-backup.txt ae-ini.txt" renames ae-backup.txt to ae-ini.txt.

del FILENAME

Delete file that has the name FILENAME. The file FILENAME is immediately deleted without any confirmation.

WARNING: Do not delete anything unless you know exactly what you are doing. MS-DOS does not have a "Recycle Bin" so you cannot recover files deleted with the "del" command.

WARNING: The character * is the wildcard character and allows you to delete all matching files by using one command, such as "del *.tmp" deletes all files that end with ".tmp" in their filename. All matching files are immediately deleted without any confirmation and cannot be recovered.

md DIRNAME

Make a new directory named DIRNAME inside the current directory. If you want to make the new directory inside a directory other than the current directory, then use the "cd" command first. For example, "md allposters" makes a new directory called "allposters" inside the current directory.

exit

Closes the MS-DOS Command Prompt window. Equivalent to clicking on the "X" close button (top right of the window frame).


For more details about DOS commands, see the How to Use DOS tutorial and the How to Use DOS blog.





E.&O.E.; © Cusimano.Com Corporation; www.c3scripts.com