You are on page 1of 12

DOS command

A command capability within DOS at all times, such as Dir, Copy, Del, Ren, Type and Cls. The internal
commands are part of DOS' COMMAND.COM file. If you delete COMMAND.COM, you can no longer
command DOS to do anything at the command line.
The other kind of commands DOS can execute are external commands. Each external command, such as
Format, Xcopy and Backup, resides in its own file in the DOS directory. If any of those files are deleted
accidentally or purposefully, you can still execute all of DOS' internal commands and any external
commands that are still left on disk.
An instruction that DOS and Windows execute from the command line or from a batch file. A variety of internal commands,
such as Dir and Copy, are built into COMMAND.COM, located in the \DOS or \WINDOWS folder. Many external
commands, such as Format and Xcopy, are individual executables that reside in the \DOS or \WINDOWS\COMMAND
folder.
DOS commands are still widely used in Windows by programmers and power users. Quite often, a typed-in command can
perform an operation much faster and much easier than dragging and dropping icons in a GUI interface.

DOS Internal Commands


Internal command
A command that is stored in the system memory and loaded from the. Below are examples of internal
commands in MS-DOS and the Windows command line currently listed in the Computer Hope
BREAK COMMAND
About break
Break can be used to enable or disable the breaking capability of the computer. For example, if a user
wanted to cancel a batch file or another MS-DOS processes, that user could press CTRL + C (break),
which would then prompt the user if they wish to cancel the current process.
Turning break off will cancel CTRL + C; however, the user will still be able to press CTRL + PAUSE/BREAK
and have the capability of getting out of a batch file / current running process.
Syntax
Sets or clears extended CTRL+C checking.
BREAK [ON | OFF]
Type BREAK without a parameter to display the current BREAK setting.
Examples
break on
Turns on the break, which allows the Ctrl + C function.
break off
Turns off the break, not allowing Ctrl + C to cancel a process.
CD COMMAND
About cd
CD (Change Directory) is a command used to switch directories in MS-DOS. For example, if you needed to run Windows
3.11 from DOS, you would type:
cd windows - Changing the directory to Windows;
win - To run the win.com file within the windows directory.
Syntax
Windows XP and later syntax

CHDIR [/D] [drive:][path]


CHDIR [..]
CD [/D] [drive:][path]
CD [..]
.. Specifies that you want to change to the parent directory.
Type CD drive: to display the current directory in the specified drive.
Type CD without parameters to display the current drive and directory.
Use the /D switch to change current drive in addition to changing current directory for a drive.
If Command Extensions are enabled CHDIR changes as follows:
The current directory string is converted to use the same case as the on disk names. So CD C:\TEMP would actually set
the current directory to C:\Temp if that is the case on disk.
CHDIR command does not treat spaces as delimiters, so it is possible to CD into a subdirectory name that contains a
space without surrounding the name with quotes. For example:
cd \winnt\profiles\username\programs\start menu
is the same as:
cd "\winnt\profiles\username\programs\start menu"
which is what you would have to type if extensions were disabled.
Examples
cd\
Goes to the highest level, the of the drive.
cd..
Goes back one directory. For example, if you are within the C:\Windows\COMMAND> directory, this would take you to
C:\Windows>
Windows 95, 98, and later versions have a feature in the CD command that allows you to go back more than one directory
when using the dots. For example, typing: cd... with three dots after the cd would take you back two directories.
cd windows
If present, would take you into the Windows directory. Windows can be substituted with any other name.
cd\windows
If present, would first move back to the root of the drive and then go into the Windows directory.
cd\windows\system32
If present, would move into the system32 directory located in the Windows directory. If at any time you need to see what
directories are available in the directory you're currently in use the .
cd /d e:\pics
If for example you were on the C: drive, typing the above command with the /d option would first switch the the E: drive
letter and then move into the pics directory.
cd
Typing cd alone will print the working directory. For example, if you're in c:\windows> and you type the cd it will print
c:\windows. For those users who are familiar with Unix / Linux this could be thought of as doing the (print working
directory) command.

CHDIR COMMAND

About chdir
Chdir (Change Directory) is a command used to switch directories in MS-DOS.
Syntax
CHDIR [drive:][path]
CHDIR[..]
CD [drive:][path]
CD[..]
Examples
chdir\
Goes to the highest level, the of the drive.
chdir..
Goes back one directory. For example, if you are within the C:\Windows\COMMAND> directory, this would
take you to C:\Windows>
Windows 95, Windows 98 and later versions of windows allow you to go back more than one directory by
using three or more dots. For example, typing chdir... with three dots after the cd would take you back
two directories.
cdhdir windows
If present, would take you into the Windows directory. Windows can be substituted with any other name.

CLS COMMAND
About cls
Cls is a command that allows a user to clear the complete contents of the screen and leave only a prompt.
Syntax
CLS
Examples
cls
Running the cls command at the command prompt would clear your screen of all previous text and only
return the .

COPY COMMAND
About copy
Allows the user to copy one or more files to an alternate location.
Syntax
Copies one or more files to another location.
COPY [/A | /B] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination] [/A | /B]] [/V] [/Y | /-Y]
The switch /Y may be preset in the COPYCMD environment variable. This may be overridden with /-Y on
the command line.
To append files, specify a single file for destination, but multiple files for source (using wildcards or
file1+file2+file3 format).
Examples

copy *.* a:
Copy all files in the current directory to the floppy disk drive.
copy autoexec.bat c:\windows
Copy the autoexec.bat, usually found at , and copy it into the windows directory; the autoexec.bat can be
substituted for any file(s).
copy win.ini c:\windows /y
Copy the win.ini file in the current directory to the windows directory. Because this file already exists in
the windows directory it normally would prompt if you wish to overwrite the file. However, with the /y
switch you will not receive any prompt.
copy "computer hope.txt" hope
Copy the file "computer hope.txt" into the hope directory. Whenever dealing with a file or directory with a
space, it must be surrounded with . Otherwise you'll get the " error.
copy myfile1.txt+myfile2.txt
Copy the contents in myfile2.txt and it with the contents in myfile1.txt.
copy con test.txt
Finally, a user can create a file using the copy con command as shown above, which creates the test.txt
file. Once the above command has been typed in, a user could type in whatever he or she wishes. When
you have completed creating the file, you can save and exit the file by pressing CTRL+Z, which would
create ^Z, and then press enter. An easier way to view and edit files in MS-DOS would be to use the .

DATE COMMAND
About date
The date command can be used to look at the current date of the computer as well as change the date to
an alternate date.
Syntax
Displays or sets the date.
DATE [date]
Type DATE without parameters to display the current date setting and
a prompt for a new one. Press ENTER to keep the same date.
Examples
date
Display the current date and prompt for a new one. If no date is entered, the current date will be kept.

DEL COMMAND
About del
is a command used to delete files from the computer.
Windows 2000 and Windows XP syntax
Deletes one or more files.
DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names

If Command Extensions are enabled DEL and ERASE change as follows:


The display semantics of the /S switch are reversed in that it shows you only the files that are deleted, not
the ones it could not find.
Examples
Notice: Users who are running Microsoft Windows 95 and are used to deleted items going to the need to
keep in mind that deleting files from MS-DOS does not send files to the recycle bin.
del test.tmp = Deletes the test.tmp in the directory that you currently are in, if the file exists.
del c:\windows\test.tmp = Delete the c:\windows\test.tmp in the windows directory if it exists.
del c:\windows\temp\*.* = (* is for wild character(s)) *.* indicates that you would like to delete all
files in the c:\windows\temp directory.
del c:\windows\temp\?est.tmp = (? is a single wild character for one letter) This command would
delete any file ending with est.tmp such as pest.tmp or zest.tmp...

DIR COMMAND
About dir
The dir command allows you to see the available files in a directory.
Examples
dir
Lists all files and directories in the directory that you are currently in.
dir *.exe
The above command lists any file that ends with the. See the for further wildcard examples.
dir *.txt *.doc
The above is using multiple filespecs to list any files ending with .txt and .doc in one command.
dir /ad
List only the directories in the current directory. If you need to move into one of the directories listed use
the.
dir /s
Lists the files in the directory that you are in and all sub directories after that directory, if you are at root
"C:\>" and type this command this will list to you every file and directory on the C: drive of the computer.
dir /p
If the directory has a lot of files and you cannot read all the files as they scroll by, you can use this
command and it will display all files one page at a time.
dir /w
If you don't need the info on the date / time and other information on the files, you can use this command
to list just the files and directories going horizontally, taking as little as space needed.
dir /s /w /p
This would list all the files and directories in the current directory and the sub directories after that, in
wide format and one page at a time.
dir /on
List the files in alphabetical order by the names of the files.
dir /o-n

List the files in reverse alphabetical order by the names of the files.
dir \ /s |find "i" |more
A nice command to list all directories on the hard drive, one screen page at a time, and see the number of
files in each directory and the amount of space each occupies.
dir > myfile.txt
Takes the output of dir and re-routes it to the file myfile.txt instead of outputting it to the screen.

Syntax
Microsoft Windows 2000, Windows XP, Windows Vista, and Windows 7 syntax
Displays a list of files and subdirectories in a directory.
DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sortorder]] [/P] [/Q] [/S]
[/T[[:]timefield]] [/W] [/X] [/4]

ECHO COMMAND
About echo
Echo is used to repeat the text typed in back to the screen and can be used to echo to a peripheral on the
computer, such as a COM port.
Syntax
Displays messages, or turns command-echoing on or off.
ECHO [ON | OFF]
ECHO [message]
Type ECHO without parameters to display the current echo setting.
Examples
Echo ata > com1
Depending if your modem was on com1, this would make the modem try responding and you should hear
some squealing from the modem. To stop the squealing, just typ echo atz > com1.
Echo echo this is a test > test.bat
This would put in the file test.bat echo this is a test, then when ever you would type in test, it would type
in echo this is a test.
Echo testing the echo string
This would type on your screen, testing the echo string, and then take you back to the prompt.
Microsoft DOS erase command
About erase
Erase is a command used to remove files from your computer's hard disk drive or other writable media.
Syntax
Deletes one or more files.
DEL [drive:][path]filename [/P]
ERASE [drive:][path]filename [/P]
Examples

Erase c:\windows\*.FAK
Delete any files that end with the FAK extension.
Notice: Users will not receive a confirmation prompt when performing this command. Once executed, all
files will be deleted unless the files have a read-only attribute and the /F switch is not being used.

EXIT COMMAND
About exit
The exit command is used to withdrawal from the currently running application and the MS-DOS session.
Syntax
Quits the COMMAND.COM program (command interpreter).
EXIT
Examples
Exit

When in another command interpreter, would exit you out of the new command interpreter
into the original.

When entering from , would return you to Windows.

If in the recovery console, would exit the and reboot the computer.

MD AND MKDIR COMMAND


About md and mkdir
Allows you to create your in MS-DOS.
Syntax
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.
Examples
md test

The above example creates the "test" directory in the current directory.
mkdir "computer hope"
The above command would create a directory called "computer hope", if you want a space in your
directory name it must be surrounded in quotes.
md c:\test
Create the "test" directory in the c:\ directory.

MOVE COMMAND
About move
Allows you to move files or directories from one folder to another, or from one drive to another.
Syntax
Moves files and renames files and directories.
To move one or more files:
MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination
To rename a directory:
MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2
The switch /Y may be present in the COPYCMD environment variable. This may be overridden with /-Y on
the command line. Default is to prompt on overwrites unless MOVE command is being executed from
within a batch script.
Examples
move c:\windows\temp\*.* c:\temp
Move the files of c:\windows\temp to the temp directory in root, this is of course assuming you have the
windows\temp directory.
move "computer hope" example
If your directory name has a space, it must be surrounded with, otherwise you will get a. error message.
In the above example, this command would move the "computer hope" directory into the example
directory contained in the same directory.

PAUSE COMMAND
About pause
The pause command is used within a computer and allows the computer to pause the currently running
batch file until the user presses any key.
Syntax
Suspends processing of a batch program and displays the message:
Press any key to continue....
PAUSE
Examples
pause

When in a stop the file until you press any key to continue.

RD / RMDIR COMMAND
About rd / rmdir
Removes empty directories in MS-DOS. To delete directories with files or directories within them the user
must use the command, or if you are running Microsoft Windows 2000 or Windows XP use the /S option.
Syntax
Removes (deletes) a directory.
RMDIR [drive:]path
RD [drive:]path
Windows 2000 and Windows XP Syntax.
RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

Removes all directories and files in the specified directory in addition to the directory itself. Used to remove a direc
/S
Quiet
/Q mode, do not ask if ok to remove a directory tree with /S.

Remove all directories


Quite mode.
Examples
rmdir c:\test
Remove the test directory, if empty. If you want to delete directories that are full, use the command or if
you're using Windows 2000 or later use the below example.
rmdir c:\test /s
Windows 2000, Windows XP and later versions of Windows can use this option with a prompt to
permanently delete the test directory and all subdirectories and files. Adding the /q switch would suppress
the prompt.

REN AND RENAME


About ren and rename
Used to rename files and directories from the original name to a new name.
In earlier releases of MS-DOS instead of using ren or rename you need to use the command to rename
your MS-DOS directories or files.
Syntax
Renames a file/directory or files/directories.
RENAME [drive:][path][directoryname1 | filename1] [directoryname2 | filename2]
REN [drive:][path][directoryname1 | filename1] [directoryname2 | filename2]
Note that you cannot specify a new drive or path for your destination.
Examples
rename c:\chope hope

Rename the directory chope to hope.


rename *.txt *.bak
Rename all text files to files with .bak extension.
rename * 1_*
Rename all files to begin with 1_. The (*) in this example is an example of a; because nothing was placed
before or after the first asterisk, this means all files in the current directory will be renamed with a 1_ in
front of the file. For example, if there was a file named hope.txt it would be renamed to 1_pe.txt.
rename "computer hope.txt" "example file.txt"
Rename the file "computer hope.txt" to "example file.txt". Whenever dealing with a file or directory with a
space, it must be surrounded with. Otherwise you'll get the error.

TIME COMMAND
About time
Allows the user to view and edit the computer's time.
Syntax
Displays or sets the system time.
TIME [time]
Type TIME with no parameters to display the current time setting and a prompt
for a new one. Press ENTER to keep the same time.
Examples
time 12:00
Set the time to 12:00

VERIFY COMMAND
About verify
Enables or disables the feature to determine if files have been written properly.
Syntax
Tells Windows whether to verify that your files are written correctly to a disk.
VERIFY [ON | OFF]
Type VERIFY without a parameter to display the current VERIFY setting.
Examples
verify on
Turn verify on.

VOL COMMAND
About vol
Displays the volume information about the designated drive.
Syntax

Displays the disk volume label and serial number, if they exist.
VOL [drive:]
Examples
vol c:
Display the volume of drive c: as shown in the below example.
Volume in drive C has no label.
Volume Serial Number is 1C24-AB20

TIME
Displays current time and allows it to be changed.
Syntax: TIME
DATE
Displays current date and allows it to be changed.
Syntax: DATE
CLS
Clears the screen.
Syntax: CLS
DIR
Shows directory information of a diskette: name, size, and the
date and time stamp of files.
Syntax: DIR [d:][path]
Optional switches:
/p Display dir info and pauses display when the screen is full
/w Display names and extensions only in five columns
To display a file directory listing for D:\LET\ANNUAL
D:\LET\ANNUAL>DIR
(from D:\LET\ANNUAL)
D:\DATA>DIR \LET\ANNUAL
(from D:\DATA)
C:\WINDOWS>DIR D:\LET\ANNUAL
(from C:\WINDOWS)
<="" a="">
COPY
Copies a file. Name of copy may be the same as original, or different.
Syntax: COPY [d:][path][name.ext] [d:][path][name.ext]
Optional switches:
/v Verify, copies the file and compares it with the original
/b Binary file
To copy a file from D:\BATCH to the root of A: drive
A:\>COPY D:\BATCH\CL.BAT
(from A: drive)
D:\BATCH>COPY CL.BAT A:\
(from D:\BATCH)
To copy a file from the root of C: to A: drive and change its name
A:\>COPY C:\MSDOS.SYS MSDOSSYS.BAK
(from A:)
C:\>COPY MSDOS.SYS A:\MSDOSSYS.BAK
(from the root of C:)
To copy all of the files from the root of A: to D:\CCV\ENGCOMP
A:\>COPY *.* D:\CCV\ENGCOMP
(from A:)
D:\CCV\ENGCOMP>COPY *.* A:\
(from D:\CCV\ENGCOMP)
TYPE
Displays the contents of a file.
Syntax: TYPE [d:][path][name.ext]
To display the contents of the file MY.LET to the screen
A:\>TYPE MY.LET
DEL
Deletes a file from disk.
Syntax: DEL [d:][path][name.ext]
To delete one file:
A:\>DEL A:\MY.LET
To del all files in current directory
A:\>DEL *.*
REN

Renames a file.
Syntax: REN [d:][path][name.ext] [d:][path][newname.ext]
To change the name of the file D:\LET\ANNUAL\99.DOC to 1999.DOC
D:\LET>REN ANNUAL\99.DOC 1999.DOC
(from D:\LET)
D:\DATA>REN \LET\ANNUAL\99.DOC 1999.DOC
(from D:\DATA)
C:\WINDOWS>REN D:\LET\ANNUAL\99.DOC 1999.DOC (from C:\WINDOWS)
MD
Makes (creates) a new directory.
Syntax: MD [d:][path][dirname]
To create a directory named HERMIT in the root of D: drive
D:\>MD HERMIT
(from D:\)
C:\>MD D:\HERMIT
(from C:\)
RD
Removes an existing directory
(directory must be empty).
Syntax: RD [d:][path][dirname]
To remove the HERMIT sub-directory
D:\>RD HERMIT
(from D:\)
C:\>RD D:\HERMIT
(from C:\)
CD
Changes the current directory.
Syntax: CD [path][dirname]
To make D:\HERMIT the current directory
D:\>CD HERMIT
(from D:\)
D:\DATA>CD \HERMIT
(from D:\DATA)
D:\DATA\SOURCE>CD \HERMIT
(from D:\DATA\SOURCE)
D:\DATA\SOURCE>CD ..
(from D:\DATA\SOURCE)
PATH
The PATH command is used to help the command interpreter find
external commands which are not in the current directory. The
command interpretter looks into the
DOS environment for "PATH=" and then searches the
paths (each separated from the next by a semicolon) that follow.
Syntax: PATH=[path;path;...]
To set the DOS PATH:
PATH=C:\DOS;C:\PCW;\C:\BIN
To display the current path:
PATH
SET PROMPT
Used to specify the appearance of the DOS prompt.
Syntax: SET PROMPT=
(from the command line)
PROMPT=
(in a batch file)
To display current drive & current path followed by ">" as prompt
SET PROMPT=$P$G
To display the current date, time, and drive on separate lines
SET PROMPT $D$_$T$_$N$G
To redefine F9 to CD\Windows\Start Menu\Programs\Startup
SET PROMPT $e[0,67;"'CD\Windows\Start Menu\Programs\Startup'";13p

You might also like