Windows - DOS Commands

Introduction to basic DOS command prompt use.

Windows 9x/2000/XP/Vista
UNSUPPORTED

NOTE: Windows 95/98, Windows Me, Windows 2000, Windows XP, and Windows Vista are no longer supported by the Help Desk. We can only provide best effort support. If we are unable to resolve your Windows 9x/2000/XP/Vista issue, you may be able to find help in Microsoft's Knowledge Base.

These products are no longer actively supported by Microsoft. No further development will take place on these products and security updates are no longer issued. It is highly recommended that you upgrade to Windows 10, 8, or 7.

Summary

DOS (Disk Operating System) was the first widely-installed operating system for IBM-compatible personal computers. DOS is a non-graphical line-oriented command-driven computer operating system. It has a relatively simple--but not overly "friendly"--user interface.

The earliest versions of the Microsoft Windows operating system were really just applications that ran on top of the MS-DOS operating system. Modern versions of Windows (Windows 95 and greater) no longer run on top of DOS, but do retain a DOS-like user interface called the "MS-DOS Prompt" or "Command Prompt". The command prompt allows Windows users to issue DOS commands to the system.

DOS commands are useful to Windows users for a variety of reasons. Many tasks that can be performed in the Windows graphical environment can be performed much more quickly and efficiently by utilizing DOS commands. Also, most bootable floppy disks will boot the system directly to a DOS environment.

Description

Users of any Windows system can invoke a command prompt by performing the following steps:
  1. Click Start.
  2. Select Run.
  3. In the "Open:" field, type command.
  4. Click OK.
A command prompt window is generally white or gray text on a black background. The prompt itself usually takes the following form:
X:\PATH>
where "X" represents the letter of the active drive, and "PATH" refers to the present working directory. Here's an example of how a DOS command prompt commonly looks:
C:\Windows>_
Command Prompt window

Commands are typed and echoed to the screen at the cursor's location. Usually commands consist of a keyword, followed by optional flags, followed by a path. More will be explained about syntax and additional flags under each specific command.

Click on a command to receive more information about it.
[INFO] [DIR] [CD] [COPY] [DEL]
[XCOPY] [DELTREE] [MOVE] [REN] [MKDIR]
[RMDIR] [ATTRIB] [PING] [TRACERT]

Important Information

Back to Menu of Commands

DIR

Displays a list of files and subdirectories in a directory.

SYNTAX

DIR [drive:][path][filename] [/P] [/W] [/A[[:]attributes]] [/O[[:]sortorder]] [/S] [/B] [/L] [/V]

EXAMPLES

Back to Menu of Commands

CD

Changes the current directory

SYNTAX
EXAMPLES
Back to Menu of Commands

COPY

Copies one or more files to another location.
See note on DOS vs. Windows file names above. If trying to copy files longer the 8 characters, DOS will truncate them with normal COPY. Also COPY will not move all files, it will leave Hidden and System files alone. Use XCOPY instead to solve both of these issues.

SYNTAX

COPY [/A | /B] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination] [/A | /B]] [/V] [/Y | /-Y]
To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format).

EXAMPLES
Back to Menu of Commands

DELETE

Deletes one or more files.

SYNTAX

DEL [drive:][path]filename [/P]
EXAMPLES
Back to Menu of Commands

XCOPY

Xcopy is a powerful version of the copy command with additional features. It has the ability to move files, directories and even whole drives from one destination to another. It also can preserve file attributes and long file names.
Note: XCOPY is in all versions of Windows, but may not run unless it is located in the command Path. Please see the note on Paths above. The actual file is called xcopy.exe and is located on Windows 98 and ME in the C:\Windows\Command directory on Windows NT and 2000 in the C:\Winnt\system32 and on Windows XP in the C:\Windows\system32 directory.

SYNTAX

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/W] [/C] [/I] [/Q] [/F] [/L] [/H] [/R] [/T] [/U] [/K] [/N]
EXAMPLES
Back to Menu of Commands

DELTREE

Deletes a directory and all the subdirectories and files in it.
Note: DELTREE is in all versions of Windows with the exception of Windows NT, 2000 and XP, but may not run unless it is located in the command path. Please see the note on Paths above. The actual file is called deltree.exe and is located in the C:\Windows\Command directory.

SYNTAX

DELTREE [/Y] [drive:]path [[drive:]path[...]]
Note: Use DELTREE cautiously. Every file and subdirectory within the specified directory will be deleted. Once deleted you cannot recover the information.

EXAMPLES
Back to Menu of Commands

MOVE

Moves files and renames files and directories.

SYNTAX

To move one or more files: MOVE [/Y | /-Y] [drive:][path]filename1[,...]destination
To rename a directory: MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2 [drive:][path]
EXAMPLES
Back to Menu of Commands

REN

Renames a file/directory or files/directories.

SYNTAX

REN [drive:][path][directoryname1 | filename1] [directoryname2 | filename2]
Note: you cannot specify a new drive or path for your destination. You can only rename files in the same directory
EXAMPLES
Back to Menu of Commands

MKDIR

Creates a directory.

SYNTAX
EXAMPLES
Back to Menu of Commands

RMDIR

Removes (deletes) a directory.

SYNTAX
EXAMPLES Back to Menu of Commands

ATTRIB

Displays or changes file attributes such as read only, hidden, system, and archive. Attrib is necessary to use most other commands that do not work when some of these attributes are set.
Note: ATTRIB is in all versions of Windows, but may not run unless it is located in the command Path. Please see the note on Paths above. The actual file is called attrib.exe and is located on Windows 98 and ME in the C:\Windows\Command directory on Windows NT and 2000 in the C:\Winnt\system32 and on Windows XP in the C:\Windows\system32 directory.

SYNTAX

ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [[drive:][path]filename] [/S]
EXAMPLES
Back to Menu of Commands

PING

Ping is used to determine if a connection exists between your computer, and another computer connected via TCP/IP. It sends small packets of information to the other computer, which are returned if the connection is found, and lost otherwise. Ping is a powerful utility to help determine network related problems.

SYNTAX

ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [[-j host-list] | [-k host-list]] [-w timeout] destination-list
EXAMPLES
Back to Menu of Commands

TRACERT

The tracert command is very similar to ping, and is used to visually see a network packet being sent and received and the amount of hops required for that packet to get to its destination. It shows you exactly how far a packet can go before it fails. This will help you know if the connection problem is close, or more towards the destination.

SYNTAX

tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name
EXAMPLES
Back to Menu of Commands
Most information on these commands were taken from www.computerhope.com which has a very extensive list of commands available.