Microsoft Disk Operating System (DOS) COMMANDS and Syntax Examples - The BASICS
Microsoft Disk Operating System (DOS) COMMANDS and Syntax Examples - The BASICS
ITEC 1250-01
Fall 2009
Special DOS Assignment
Table of Contents
1
1. attrib
Displays or changes file attributes.
+ Sets an attribute.
- Clears an attribute.
R Read-only file attribute.
A Archive file attribute.
S System file attribute.
H Hidden file attribute.
[drive:][path][filename]
Specifies a file or files for attrib to process.
/S Processes matching files in the current folder
and all subfolders.
/D Processes folders as well.
2. cd
Displays the name of or changes the current directory.
1
CD into a subdirectory name that contains a space without surrounding
the name with quotes. For example:
cd \winnt\profiles\username\programs\start menu
cd "\winnt\profiles\username\programs\start menu"
3. chkdsk
Checks a disk and displays a status report.
2
EXAMPLE: chkdsk a: checks the a: drive
4. cls
Clears the screen.
CLS
5. command
Starts a new instance of the MS-DOS command interpreter.
6. color
Sets the default console foreground and background colors.
COLOR [attr]
0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
3
6 = Yellow E = Light Yellow
7 = White F = Bright White
7. copy
Copies one or more files to another location.
COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
[+ source [/A | /B] [+ ...]] [destination [/A | /B]]
To append files, specify a single file for destination, but multiple files
for source (using wildcards or file1+file2+file3 format).
4
8. date
Displays or sets the date.
9. drvspace
Compresses hard disk drives or floppy disks, and configures drives that were compressed
using DriveSpace.
DRVSPACE /COMPRESS compress a hard disk drive or floppy disk.
DRVSPACE /CREATE Create a new compressed drive in the free space on an
existing drive.
DRVSPACE /DEFRAGMENT Defragment a compressed drive.
DRVSPACE /DELETE delete a compressed drive. For
DRVSPACE /FORMAT Format a compressed drive.
DRVSPACE /INFO Display information about a compressed drive.
DRVSPACE /LIST Display a list of the drives on your computer. The list includes
compressed and uncompressed hard disk drives, floppy disk drives, and other removable-
media drives. It does not include network drives.
DRVSPACE /MOUNT mount a compressed volume file (CVF). When DriveSpace
mounts a CVF, itassigns it a drive letter; you can then use the files that CVF contains.
DRVSPACE /RATIO Change the estimated compression ratio of a compressed drive.
DRVSPACE /SIZE Change the size of a compressed drive
DRVSPACE /UNCOMPRESS Uncompress a compressed drive.
DRVSPACE.INI Change the settings in your DRVSPACE.INI file
EXAMPLE: DRVSPACE /COMPRESS a:\
5
10. defrag
Usage:
defrag <volume> [-a] [-f] [-v] [-?]
volume drive letter or mount point (d: or d:\vol\mountpoint)
-a Analyze only
-f Force defragmentation even if free space is low
-v Verbose output
-? Display this help text
EXAMPLE: DEFRAG C: -A
11. DEl
Deletes one or more files.
EXAMPLE : DEL /P /A : A
12. Deltree
Deletes a directory and all the subdirectories and files in it.
To delete one or more files and directories: DELTREE [/Y] [drive:]path
[[drive:]path[...]]
6
/Y Suppresses prompting to confirm you want to delete the subdirectory.
[drive:]path Specifies the name of the directory you want to delete.
Note: Use DELTREE cautiously. Every file and subdirectory within the specified
directory will be deleted. Once deleted, you cannot recover the information.
13. dir
Displays a list of files and subdirectories in a directory.
[drive:][path][filename]
Specifies drive, directory, and/or files to list.
7
Switches may be preset in the DIRCMD environment variable. Override
preset switches by prefixing any switch with - (hyphen)--for example, /-W.
14. diskcopy
Copies the contents of one floppy disk to another.
15. doskey
Edits command lines, recalls Windows XP commands, and creates macros.
UP and DOWN ARROWS recall commands; ESC clears command line; F7 displays
command history; ALT+F7 clears command history; F8 searches command
history; F9 selects a command by number; ALT+F10 clears macro definitions.
8
The following are some special codes in Doskey macro definitions:
$T Command separator. Allows multiple commands in a macro.
$1-$9 Batch parameters. Equivalent to %1-%9 in batch programs.
$* Symbol replaced by everything following macro name on command line.
16. edit
MS-DOS Editor Version 2.0.026 Copyright (c) Microsoft Corp 1995.
17. emm368
Turns on or off EMM386 expanded memory support.
EMM386 [ON | OFF | AUTO] [W=ON | W=OFF]
ON | OFF | Activates or suspends EMM386.EXE device driver, or places it in auto
AUTO mode.
W=ON | OFF Turns on or off weitek coprocessor support.
9
18. exit
Quits the CMD.EXE program (command interpreter) or the current batch
script.
19. fdisk
Configures a hard disk for use with MS-DOS.
FDISK [/STATUS] /X
/STATUS Displays partition information.
/X Ignores extended disk-access support (will not use LBA support). Use this switch if
you receive one of the below symptoms.
Unable to access a drive from DOS versions prior to 7.
Disk access messages.
Stack overflows messages.
High amounts of data corruption.
Extra drive letters
10
[drive:][path]filename
Specifies a file or files to search.
If a path is not specified, FIND searches the text typed at the prompt
21. Format
Formats a disk for use with Windows XP.
Note that the FAT and FAT32 files systems impose the
following restrictions on the number of clusters on a volume:
11
above 4096.
EXAMPLE: format a: /q
22. KeyB
Configures a keyboard for a specific language.
KEYB [xx[,[yyy][,[drive:][path]filename]]] [/E] [/ID:nnn]
xx Specifies a two-letter keyboard code.
yyy Specifies the code page for the character set.
[drive:][path]filename Specifies the keyboard definition file.
/E Specifies that an enhanced keyboard is installed.
/ID:nnn Specifies the keyboard in use.
23. LABEL
Creates, changes, or deletes the volume label of a disk.
LABEL [drive:][label]
LABEL [/MP] [volume] [label]
12
24. Loadhigh (Lh)
25. mem
Displays the amount of used and free memory in your system.
26. mkdir
Creates a directory.
MKDIR [drive:]path
MD [drive:]path
13
MKDIR creates any intermediate directories in the path, if needed.
For example, assume \a does not exist then:
mkdir \a\b\c\d
27. mode
Configures system devices.
14
28. more
Displays output one screen at a time.
Files List of files to be displayed. Files in the list are separated by blanks.
15
29. MOVE
Moves files and renames files and directories.
To rename a directory:
MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2
30. path
Displays or sets a search path for executable files.
PATH [[drive:]path[;...][;%PATH%]
PATH ;
Type PATH ; to clear all search-path settings and direct cmd.exe to search
only in the current directory.
Type PATH without parameters to display the current path.
Including %PATH% in the new path setting causes the old path to be
appended to the new setting.
16
31. prompt
Changes the MS-DOS command prompt.
PROMPT [text]
Prompt can be made up of normal characters and the following special codes:
$Q = (equal sign)
$$ $ (dollar sign)
$T Current time
$D Current date
$P Current drive and path
$V MS-DOS version number
$N Current drive
$G > (greater-than sign)
$L < (less-than sign)
$B | (pipe)
$H Backspace (erases previous character)
$E Escape code (ASCII code 27)
$_ Carriage return and linefeed
Type PROMPT without parameters to reset the prompt to the default setting.
EXAMPLE: Prompt $b $ d
32. rename
Renames a file or files.
Note that you cannot specify a new drive or path for your destination file.
EXAMPLE:
17
33. rmdir
Removes (deletes) a directory.
34. scandisk
Below is a listing of available switches in MS-DOS scandisk 6.2 and above. It is important
to note that these commands will not work in Windows 95 and above.
18
/nosave Deletes all lost clusters found by Scandisk. Can be used with /autofix.
Prevents display of full-screen summary after each drive. Use with
/nosummary
/autofix to prevent prompts for undo diskette.
35. setver
36. smartdrv
SMARTDRV [/X] [[drive[+|-]]...] [/U] [/C | /R] [/F | /N] [/L] [/V | /Q | /S]
[InitCacheSize [WinCacheSize]] [/E:ElementSize] [/B:BufferSize]
drive Sets caching options on specific drive(s). The specified drive(s) will have
write-caching disabled unless you add +.
19
- Disables all caching for the specified drive.
37. start /w
Starts a separate window to run a specified program or command.
20
REALTIME Start application in the REALTIME priority class
ABOVENORMAL Start application in the ABOVENORMAL priority class
BELOWNORMAL Start application in the BELOWNORMAL priority class
WAIT Start application and wait for it to terminate
command/program
If it is an internal cmd command or a batch file then
the command processor is run with the /K switch to cmd.exe.
This means that the window will remain after the command
has been run.
When executing a command line whose first token is the string "CMD "
without an extension or path qualifier, then "CMD" is replaced with
the value of the COMSPEC variable. This prevents picking up CMD.EXE
from the current directory.
When executing a command line whose first token does NOT contain an
extension, then CMD.EXE uses the value of the PATHEXT
environment variable to determine which extensions to look for
and in what order. The default value for the PATHEXT variable
is:
.COM;.EXE;.BAT;.CMD
21
semicolons separating the different elements.
EXAMPLE: start w/ ‘DOS’ will start a new window with DOS as title in the title bar.
38. subst
Associates a path with a drive letter.
EXAMPLE: subs f: .
39. Sys
Copies MS-DOS system files and command interpreter to a disk you specify.
22
40. time
Displays or sets the system 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.
EXAMPLE: TIME /T only display the time without prompting for input for new time.
41. type
Displays the contents of a text file or files.
TYPE [drive:][path]filename
42. ver
Displays the Windows XP version.
VER
EXAMPLE: VER
43. verify
Tells cmd.exe whether to verify that your files are written correctly to a
disk.
EXAMPLE: verify on
44. vol
Displays the disk volume label and serial number, if they exist.
23
VOL [drive:]
45. xcopy
Copies files and directory trees.
XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
[/EXCLUDE:file1[+file2][+file3]...]
24
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.
EXAMPLE xcopy a:\ c:\progra~1\myfolder /a copies whatever folder or file from a: to C:+ path
IMPORTAN FILES
AUTOEXEC.BAT
The autoexec is a system file originally found in MS-DOS. It is plain-text batch file that resides
in the root directory. The file name stands for automatic execution. The AUTOEXEC.BAT
executes commands on system startup.
CONFIG.SYS
Config.sys is used with MS-DOS, and it’s loaded each time the computer first boots up. The
CONFIG.SYS controls components of computer that are connected. CONFIG.SYS control
memory and other hardware devices.
25