MS-DOS Basics - A Tutorial
MS-DOS Basics - A Tutorial
MS-DOS Basics - A Tutorial
This tutorial gives you an opportunity to try basic MS-DOS commands. By following the
procedures in this section, you will learn to:
o View the contents of a directory
o Change from one directory to another
o Create and delete directories
o Change from one drive to another
o Copy files
o Rename files
o Delete files
o Format a floppy disk
The Command Prompt
When you first turn on your computer, you will see some cryptic information flash by.
MS-DOS displays this information to let you know how it is configuring your computer.
You can ignore it for now. When the information stops scrolling past, you'll see the
following:
C:\>
This is called the command prompt or DOS prompt. The flashing underscore next to
the command prompt is called the cursor. The cursor shows where the command you
type will appear.
Typing a Command
This section explains how to type a command at the command prompt and demonstrates
the "Bad command or file name" message.
To type a command at the command prompt
1. Type the following at the command prompt (you can type the command in either
Directory of C:\DIRNAME
o To change from the root directory to the WINDOWS directory
To change directories, you will use the cd command. The cd command stands for
"change directory."
1. Type the following at the command prompt:
cd windows
The command prompt changes. It should now look like the following:
C:\WINDOWS>
Next, you will use the dir command to view a list of the files in the DOS directory.
o To view a list of the files in the WINDOWS directory
1. Type the following at the command prompt:
dir
A list of the files in the WINDOWS directory appears, but scrolls by too quickly to read.
You can modify the dir command so that it displays only one screen of information at a
time.
o To view the contents of a directory one screen at a time
1. Type the following at the command prompt:
dir /p
One screen of information appears. At the bottom of the screen, you will see the
following message:
Press any key to continue . . .
2. To view the next screen of information, press any key on your keyboard.
Repeat this step until the command prompt appears at the bottom of your screen.
When you typed the dir command this time, you included the /p switch after the
command. A switch modifies the way MS-DOS carries out a command. Generally, a
switch consists of a forward slash (/) that is followed by one or more letters or numbers.
When you used the /p switch with the dir command, you specified that MS-DOS should
pause after it displays each screen of directory list information. The p actually stands for
"page"
Another helpful switch you can use with the dir command is the /w switch. The /w
switch indicates that MS-DOS should show a wide version of the directory list.
o To view the contents of a directory in wide format
1. Type the following at the command prompt:
dir /w
The directory list appears, with the filenames listed in wide format. Note that only
filenames are listed. No information about the files' size or date and time of creation
appears.
2. If the directory contains more files than will fit on one screen, you can combine the /p
and /w switches as follows:
dir /w /p
Changing Back to the Root Directory
Next, you will change from the DOS directory to the root directory. The root
directory is the directory you were in before you changed to the DOS directory.
Before you begin this section, make sure your command prompt looks like the
following:
C:\DOS>
o To change to the root directory
1. Type the following at the command prompt:
cd \
Note that the slash you type in this command is a backslash (\), not a forward
slash (/).
No matter which directory you are in, this command always returns you to the
root directory of a drive. The root directory does not have a name. It is simply
referred to by a backslash (\).
The command prompt should now look like the following:
C:\>
When your command prompt appears similar to this---that is, when it does not
contain the name of a directory---you are in the root directory.
Creating a Directory
In this section, you will create two directories. Creating a directory is helpful if
you want to organize related files into groups to make them easy to find. Before
you begin this section, make sure the command prompt looks like the following:
C:\>
To create a directory, you will use the md command. The md command stands
for "make directory."
o To create and change to a directory named FRUIT
1. Type the following at the command prompt:
md fruit
You have now creat ed a directory named FRUIT. You won't see the new FRUIT
directory until you carry out the dir command in the next step.
2. To confirm that you successfully created the FRUIT directory, type the
following at the command prompt:
dir
or
dir /p
Look through the directory list. A new entry somewhere in the list should look
similar to the following:
FRUIT <DIR> 09-25-93 12:09p
3. To change to the new FRUIT directory, type the following at the command
prompt:
cd fruit
The command prompt should now look like the following:
C:\FRUIT>
You will now create a directory within the FRUIT directory, named GRAPES.
o To create and work with a directory named GRAPES
1. Type the following at the command prompt:
md grapes
You will not see the new GRAPES directory until you carry out the dir command in the
next step.
2. To confirm that you successfully created the GRAPES directory, type the following at the
command prompt:
dir
A list similar to the following appears:
Volume in drive C is MS-DOS-6
Volume Serial Number is lE49-15E2
Directory of C:\FRUIT
. <DIR> 09-25-93 12:08p
.. <DIR> 09-25-93 12:08p
GRAPES <DIR> 09-25-93 12:10p
3 file(s) 0 bytes
In this section, you will delete the GRAPES directory. Before you begin this
section, make sure the command prompt looks like the following:
C:\FRUIT>
To delete a directory, use the rd command. The rd command stands for "remove
directory."
o To delete the GRAPES directory
1. Type the following at the command prompt:
rd grapes
2. To confirm that you successfully deleted the GRAPES directory, type the following at the
command prompt:
dir
The GRAPES directory should no longer appear in the directory list.
Note You cannot delete a directory if you are in it. Before you can delete a
directory, you must make the directory that is one level higher the current
directory. To do this, type cd.. at the command prompt.
Changing Drives
This section describes how to change drives. Changing drives is useful if you
want to work with files that are on a different drive.
So far, you have been working with driveC. You have other drives you can use
to store information. For example, drive A is your first floppy disk drive. The
files and directories on drive A are located on the floppy disk in the drive. (You
might also have a drive B, which contains the files and directories stored on the
floppy disk in that drive.)
Before you begin this section, make sure your command prompt looks like the
following:
C:\FRUIT>
o To change to and view files on a different drive
1. Insert a 3.5" floppy disk in drive A label- side up. Make sure the disk clicks
into the drive.
1. Type the following at the command prompt:
a:
Note that the command prompt changed to the following:
A:\>
This message may appear:
Not ready reading drive A
Abort, Retry, Fail?
If you see this message, the disk may not be inserted properly. Place the disk label-side
up in the disk drive, and make sure the disk clicks into the disk drive. Then, type r for
Retry. If this message appears again, press F for Fail, and then type b: at the command
prompt. If you no longer see this message, type b: instead of a: throughout the rest of the
tutorial.
There must be a floppy disk in the drive that you want to change to.
2. Change back to drive C by typing the following at the command prompt:
c:
Your command prompt should return to the following:
C:\FRUIT>
When you type a drive letter followed by a colon, you change to that drive. The drive
letter that appears in the command prompt shows which drive is the current drive. Unless
you specify otherwise, any commands you type are carried out on the current drive and in
the current directory.
So far, all the commands you typed were carried out on the current drive and in the
current directory. You can also carry out a command on a drive that isn't current. For
example, you can view the files on a disk in drive A without switching to drive A by
following this procedure.
o To view the contents of the WINDOWS directory on drive C
1. Type the following at the command prompt:
dir c:\windows
A list of the files in the DOS directory on drive C should scroll past on your screen.
Copying Files
This section describes how to copy a single file and a group of files. Copying files creates
a duplicate of the original file and does not remove the original file. This is useful for
many reasons. For example, if you want to work on a document at home, you can copy it
from your computer at work to a floppy disk and then take the floppy disk home.
To copy a file, you will use the copy command. When you use the copy command, you
must include two parameters. The first is the location and name of the file you want to
copy, or the source. The second is the location to which you want to copy the file, or the
destination. You separate the source and destination with a space. The copy command
follows this pattern:
copy source destination
Copying a Single File
In this section, you will copy the notepad.exe files from the WINDOWS directory to the FRUIT
directory. You will specify the source and destination of these files in two different ways. The
difference between the two methods is explained at the end of this section.
Before you begin this section, make sure the command prompt looks like the following:
C:\FRUIT>
To copy the NOTEPAD.EXE files from the WINDOWS directory to the FRUIT directory
1. Return to the root directory by typing the following at the command prompt:
cd\
The command prompt should now look like the following:
C:\>
Change to the DOS directory by typing the following at the command prompt:
cd windows
The command prompt should now look like the following:
C:\WINDOWS>
2. Make sure the file you are going to copy, NOTEPAD.EXE, is located in the WINDOWS
directory
by using the dir command followed by a filename.
dir notepad.exe
A list similar to the following appears:
3. To copy the NOTEPAD.EXE file from the WINDOWS directory to the FRUIT directory, type
the
following at the command prompt:
copy c:\windows\notepad.exe c:\fruit
The following message appears:
1 file(s) copied
4. To confirm that you copied the files successfully, view the contents of the FRUIT directory by
typing the following at the command prompt:
dir \fruit
You should see the file listed in the FRUIT directory.
Renaming Files
This section explains how to rename files. You may want to rename a file if the information in it
changes or
if you decide you prefer another name.
To rename a file, you will use the ren command. The ren command stands for "rename." When
you use
the ren command, you must include two parameters.
The first is the file you want to rename, and the second is the new name for the file. You separate
the two
names with a space. The ren command follows this pattern:
ren oldname newname
Renaming a File
In this section, you will rename the README.TXT file.
Before you begin this section, make sure your command prompt looks like the following:
C:\FRUIT>
1. To rename the NOTEPAD.EXE file to PADNOTE.TXT, type the following at the command
prompt:
ren notpad.exe padnote.txt
2. To confirm that you renamed the file successfully, type the following at the command prompt:
dir
Deleting Files
This section explains how to delete, or remove, a file that you no longer want on your disk. If
you dont
have very much disk space, deleting files you no longer use is essential.
To delete a file, you will use the del command. The del command stands for "delete."
Deleting a File
In this section, you will delete two files using the del command.
Before you begin, make sure your command prompt looks like the following:
C:\FRUIT>
To delete the PEARCOM and PEAR.HLP files
1. Delete the PADNOTE.TXT file by typing the following at the command prompt:
del PADNOTE.TXT
2. To confirm that you deleted the files successfully, type the following at the command prompt:
dir
Deleting a Group of Files
In this section, you will use wildcards to delete a group of files.
Before you begin this section, make sure your command prompt looks like the following:
C:\FRUIT>
To delete files in the current directory that end with the extension OLD by using wildcards
1. View all files that end with the extension OLD by typing the following at the command
prompt:
dir *.old
A list of all the files that end with the extension OLD appears. Make sure that these are the files
you want to delete. When you are deleting files by using wildcards, this step is very important. It
will prevent you from deleting files accidentally.
2. Delete all files ending with OLD by typing the following at the command prompt:
del *.old
3. To confirm that all the files with the extension OLD have been deleted, type the following at
the
command prompt:
dir
The FRUIT directory should contain no files.
Now that the FRUIT directory is empty, you can delete it by using the rd (remove directory)
command that
Example: AUTOEXEC.BAT
The following characters are reserved and cannot be used in an
MS DOS environment
Colon:
Semicolon;
Slashes / \
Spaces
Greater than >
Less than <
Question mark?
Asterisk *
Period.
Dollar sign $
Quotes marks " "
Apostrophes ' '
Pipe sign |
Valid DOS names
AUTOEXEC.BAT, CONFIG.SYS, NAME.DOC, HELLO.TXT
Invalid DOS names
AUTOEXEC233.BAT, <Good>.EXE, NAME$. DOC
To remove a directory
C:\>RD or RMDIR example (removes the example directory)
To change a directory
C:\>CD or CHDIR example (press enter)
C:\>EXAMPLE ( I am now in the example directory)
directories)
C:\>XCOPY EXAMPLE NEW (copies example directory into new
directory)
If no date is given, copies only those files whose
source time is newer than the destination time.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except empty ones.
/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
/W Prompts you to press a key before copying.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file names while copying.
/L Displays files that would be copied.
/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 Updates the files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/Y Overwrites existing files without prompting.
/-Y Prompts you before overwriting existing files.
C:\>DEFRAG
To run a diagnostic program in DOS (only available in DOS 6.22)
C:\>MSD
To run an anti-virus program in DOS (only available in DOS 6.22)
C:\>MSAV
TCP/IP Utilities
WINIPCFG - A GUI utility on Windows 9x that allows you to get info
about your IP configuration. It also allows you to release a DHCP
lease and request a new one.
Windows 98 IP Configuration
Host Name . . . . . . . . . : ESCOTAL.rcnchicago.com
DNS Servers . . . . . . . . : 207.229.143.1
207.229.143.2
Node Type . . . . . . . . . : Broadcast
NetBIOS Scope ID. . . . . . :
IP Routing Enabled. . . . . : No
WINS Proxy Enabled. . . . . : No
NetBIOS Resolution Uses DNS : No
Ethernet adapter :
Description . . . . . . . . : PPP Adapter.
Physical Address. . . . . . : 44-45-53-54-00-00
DHCP Enabled. . . . . . . . : Yes
IP Address. . . . . . . . . : 0.0.0.0
Subnet Mask . . . . . . . . : 0.0.0.0
Default Gateway . . . . . . :
6 10 ms 10 ms 11 ms 0.so-3-0-0.TR1.CHI4.ALTER.NET
[152.63.15.234]
7 22 ms 23 ms 24 ms 106.at-6-1-0.TR1.ATL5.ALTER.NET
[146.188.142.33]
8 23 ms 26 ms 24 ms 197.at-1-0-0.XR1.ATL5.ALTER.NET
[152.63.80.241]
9 23 ms 24 ms 26 ms 193.ATM6-0.GW5.ATL5.ALTER.NET
[152.63.82.9]
10 * * * Request timed out.
11 39 ms 25 ms 25 ms 64.224.0.99
12 24 ms 24 ms 26 ms www.escotal.com [64.224.226.151]
Trace complete.
Usage: tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout]
target_name
Options:
-d Do not resolve addresses to hostnames.
-h maximum_hops Maximum number of hops to search for target.
-j host-list Loose source route along host-list.
-w timeout Wait timeout milliseconds for each rep
Other DOS commands
NSLOOKUP enables you to determine the name of a DNS server
C:\>nslookup www.escotal.com
COMPACT displays or alters the compression of on files on NTFS
partitions
C:\>compact>compact /c
dir /a
Suppose you want DIR to display one directory listing after another, until it has displayed the
listing for
every directory on the disk in the current drive. Suppose also that you want DIR to alphabetize
each
directory listing, display it in wide format, and pause after each screen. To specify such a display,
be sure
the root directory is the current directory and then type the following command:
dir /s/w/o/p
DATE
MS-DOS records the current date for each file you create or change; this date is listed next to the
filename
in the directory.
Syntax
DATE [mm-dd-yy]
Parameter
mm-dd-yy
Sets the date you specify. Values for day, month, and year must be separated by periods (.),
hyphens (-), or
slash marks (/). The date format depends on the COUNTRY setting you are using in your
CONFIG.SYS
file. The following list shows the valid values for the month, day, and year portions of the mmdd-yy
parameter.
mm 1 through 12
dd 1 through 31
TIME 13:36
TIME 1:36p
FORMAT
To format a new floppy disk in drive A using the default size, type the
format a:
To perform a quick format on a previously formatted disk in drive A, type the following
command:
format a: /q
To format a floppy disk in drive A, completely deleting all data on the disk, type the following
command:
DOS COMMAND EXAMPLES
2
format a: /u
To format a 360K floppy disk in drive A and copy the operating system files to the disk to make
it a system
disk, type the following command:
format a: /f:360 /s
To format a floppy disk in drive A and assign to it the volume label "DATA", type the following
command:
format a: /v:DATA
SYS
To copy the MS-DOS system files and command interpreter from the disk in the current drive to
a disk in
drive A, type the following command:
sys a:
To copy the MS-DOS system files and command interpreter from a disk in drive B to a disk in
drive A,
type the following the command:
sys b: a:
PROMPT
The following example sets the command prompt to display the current drive and path followed
by the
greater-than sign (>):
prompt $p$g
The following command displays a two-line prompt in which the current time appears on the
first line and
the current date appears on the second line:
following command:
diskcomp a: a:
COPY
The following command copies a file and ensures that an end-of-file character is at the end of the
copied
file:
To copy the NOTE.TXT file from the current drive and directory to the directory MYNOTES,
and to
prevent MS-DOS from prompting you before overwriting the destination file (if it already
exists), type the
following command:
If the BIRDS directory doesn't exist, MS-DOS copies the file ROBIN.TYP into a file named
BIRDS that is
located in the root directory on the disk in drive C.
To copy several files into one file, list any number of files as source parameters on the COPY
command
line. Separate filenames with a plus sign (+) and specify a filename for the resulting combined
file, as the
following example shows:
This command combines the files named MAR89.RPT, APR89.RPT, and MAY89.RPT from the
current
drive and directory and places them in a file named REPORT in the current directory on the
current drive.
When files are combined, the destination file is created with the current date and time. If you
omit
destination, MS-DOS combines the files and stores them under the name of the first specified
file. For
example, if a file named REPORT already exists, you can use the following command to
combine all four
files in REPORT:
You can also combine several files into one by using wildcards, as the following example shows:
This command combines all files in the current directory on the current drive that have the
extension .TXT
into one file named COMBIN.DOC, also in the current directory on the current drive.
If you want to combine several binary files into one by using wildcards, include the /B switch, as
the
following example shows:
CAUTION: If you combine binary files, the resulting file might not be usable due to internal
formatting.
In the following example, COPY combines each file that has a .TXT extension with its
corresponding .REF
file. The result is a file with the same filename but with a .DOC extension. Thus, COPY
combines
FILE1.TXT with FILE1.REF to form FILE1.DOC. Then COPY combines FILE2.TXT with
FILE2.REF to
form FILE2.DOC, and so on.
The following COPY command combines first all files with the .TXT extension, then all files
with the
.REF extension into one file named COMBIN.DOC:
The following COPY command copies what you type at the keyboard to the OUTPUT.TXT file:
DOS COMMAND EXAMPLES
4
After you type this command and press ENTER, MS-DOS copies everything you type to the file
OUTPUT.TXT. When you are finished typing, press CTRL+Z to indicate that you want to end
the file. The
CTRL+Z character will appear on the screen as "Z". You can also end a COPY CON command
by pressing
the F6 key. When you press F6, it generates the CTRL+Z character, which appears on the screen
as Z.
The following example copies information from the keyboard to the printer connected to LPT1:
Suppose you want to change the extensions of all the filenames in the current directory that have
the
extension .TXT; for example, suppose you want to change the .TXT extensions to .DOC
extensions. To
make this change, type the following command:
To rename a file named CHAP10 (on drive B) to PART10, type the following command:
del c:\test\cat.tmp
erase c:\test\cat.tmp
To delete all the files in a directory named TEST on drive C, you can use either of the following
commands:
del c:\test
del c:\test\*.*
UNDELETE
The following command specifies that UNDELETE is to recover all deleted files in the current
directory
one at a time, to prompt for confirmation on each file, and to use the highest available level of
delete
tracking:
undelete
The following command specifies that UNDELETE is to recover all deleted files with the .BAT
extension
in the root directory of drive C, without prompting for confirmation on each file:
undelete /sc
The following command loads the memory-resident portion of the UNDELETE program into
memory and
creates a PCTRACKER.DEL file to track up to 400 deleted files on drive C:
undelete /tc-400
MD
Suppose you want to create a directory on the disk in the current drive and use the directory to
store all
your tax information. To create a directory named TAXES, type the following command:
mkdir \taxes
You could also type this command with the same results:
md \taxes
Now suppose that the TAXES directory is the current directory and that you want to create a
subdirectory
of TAXES named PROPERTY. To create the PROPERTY directory, type the following
command:
mkdir property
CD
Either of the following commands changes your current directory to the directory named
PRIMETIME:
chdir \primetime
cd \primetime
Suppose you have a directory named SPECIALS with a subdirectory named SPONSORS. To
change your
current directory to \SPECIALS\SPONSORS, type the following command:
cd \specials\sponsors
Or, if your current directory is \SPECIALS, you can use the following command to change to the
\SPECIALS\SPONSORS directory:
cd sponsors
To change from a subdirectory back to the parent directory, type the following command:
cd..
To display the name of the current directory, you can use CHDIR or CD without a parameter. For
example,
if your current directory is \PUBLIC\JONES on the disk in drive B, type CHDIR to see the
following
response:
B:\PUBLIC\JONES
chdir c:\public\jones
copy c:*.* d:\
chdir c:\public\lewis
copy c:*.* d:\
If, instead, you want to copy all files in the \PUBLIC\JONES and \PUBLIC\LEWIS directories
to your
current location on drive D, type the following commands:
chdir c:\public\jones
copy c:*.* d:
chdir c:\public\lewis
copy c:*.* d:
RD
To delete a directory named \USER\SMITH, first ensure that the directory is empty, as in the
following
example:
dir \user\smith /a
Then, from any directory except \USER\SMITH, type the following command:
rmdir \user\smith
You can type the following command with the same result:
rd \user\smith
PATH
The following command specifies that MS-DOS is to search three directories to find commands
(the three
paths for these directories are C:\USER\TAXES, B:\USER\INVEST, and B:\BIN):
path c:\user\taxes;b:\user\invest;b:\bin
TREE
To display the names of all the subdirectories on the disk in your current
drive, type the following command:
tree \
To display, one screen at a time, the files in all the directories on drive C, type the following
command:
To print the same list that the previous example displayed, type the following command:
To move the BILL.TXT file from the current directory to the LETTERS directory on drive C and
rename it
ANN.TXT, type the following at the command prompt:
To rename the THISYEAR directory on drive C to LASTYEAR, type the following at the
command
prompt:
deltree c:\temp
CHKDSK
To find out how much data is stored on drive C and how much space is still free, and to check the
disk for
errors, type the following command:
chkdsk c:
To redirect the output of CHKDSK to a file named STATUS, type the following command:
Because the output is redirected, MS-DOS does not repair errors it encounters during the check;
but it
records all the errors in a report file. Afterward, you can use CHKDSK with the /F switch
without
redirection to correct any errors noted in the status report.
SCANDISK
To check and fix the current drive, type the following:
scandisk
Suppose that DriveSpace is installed, but is unable to mount your compressed drive because of
problems
with the drive. The drive's compressed volume file is called DRVSPACE.000 and is located in
the root
directory of drive C. To repair the volume file, type the following:
scandisk c:\DRVSPACE.000
The DriveSpace volume file must be located in the root directory of the drive.
scandisk c: e:
scandisk /all
This will check all your hard disk partitions, in addition to all mounted DriveSpace drives (if
DriveSpace is
installed).
Suppose you created an Undo disk, did not change the contents of the checked drive since you
created the
Undo disk, and placed the Undo disk in drive A. To undo the changes made by ScanDisk, type
the
following:
scandisk /undo a:
UNFORMAT
To determine whether UNFORMAT can restore a formatted disk in drive A, type the following
command:
unformat a: /test
To restore a formatted disk in drive A, listing all files and subdirectories, type the following
command:
unformat a: /l
DEFRAG
To load DEFRAG into conventional memory and specify that DEFRAG sort files according to
the date
they were created, from latest created to earliest created, type the following command:
msav /bw /a
To write a simple batch program named VIRUS that supports the MSAV exit code and the /S
switch to
scan the current drive, you can type the following commands by using MS-DOS Editor:
echo off
rem Smith's msav command
msav /s /n
if errorlevel 86 goto virus
if not errorlevel 86 goto none
:virus
DOS COMMAND EXAMPLES
9
echo MSAV has detected a virus on your current drive!
goto exit
:none
echo MSAV found no viruses on your current drive.
goto exit
:exit
VSAFE
To specify that VSAFE not check for formatting that could erase all data on the hard disk, that
VSAFE
warn of attempts to write to the boot sector of a floppy disk, and that ALT+T be assigned as the
hot key to
display the VSAFE screen, type the following command:
To specify that VSAFE not check for formatting that could erase all data on the hard disk, that
VSAFE
warn of attempts to write to the boot sector of a floppy disk, and that ALT+T be assigned as the
hot key to
display the VSAFE screen, type the following command:
msd
The MSD program has an interface that makes it easy for you to access detailed technical
information
about your computer.
Creating a report
Before calling Microsoft Product Support Services, you could create a file called
COMPUTER.TXT that
contains a detailed technical report about your computer. To do this, you could type the following
at the
command prompt:
msd /p computer.txt
The COMPUTER.TXT file would contain the information about your computer.
If you want MSD to create a detailed report about your computer and you wanted the report to
include such
information as your name, company, address, and phone number, you would type the following
at the
command prompt:
msd /f computer.txt
attrib news86
To assign the Read-Only attribute to the file REPORT.TXT, type the following command:
attrib +r report.txt
To remove the Read-Only attribute from files in the \PUBLIC\JONES directory on a disk in
drive B and
from files in any subdirectories of \PUBLIC\JONES, type the following command:
attrib -r b:\public\jones\*.* /s
As a final example, suppose you want to give an associate a disk containing all files in the
default directory
on a disk in drive A except files with the .BAK extension. Because you can use <XCOPY> to
copy only
those files marked with the Archive attribute, you need to set the Archive attribute for those files
you want
to copy. To do this, you would use the following two commands to set the Archive attribute for
all files on
drive A and then to clear the attribute for those files with the .BAK extension:
attrib +a a:*.*
attrib -a a:*.bak
Next, use the XCOPY command to copy the files from the disk in drive A to the disk in drive B.
The /A
switch in the following command causes XCOPY to copy only those files marked with the
Archive
attribute:
xcopy a: b: /a
If you want XCOPY to clear each file's Archive attribute after it copies the file, use the /M switch
instead
of /A, as in the following example:
xcopy a: b: /m
XCOPY
The following example copies all the files and subdirectories (including any empty
subdirectories) from the
disk in drive A to the disk in drive B:
xcopy a: b: /s /e
xcopy a: b: /d:01/18/93 /s /v
In this example, only files on the disk in drive A that were written on or after 01/18/93 are copied
to the
disk in drive B. Once the files are written to the disk in drive B, the XCOPY command compares
the files
on the two disks to make sure they are the same.
the exit code in case an error occurs. For example, the following batch program uses replaceable
parameters for the XCOPY source and destination parameters:
@echo off
rem COPYIT.BAT transfers all source
rem files in all directories on the source
rem drive (%1) to the destination drive (%2)
xcopy %1 %2 /s /e
REPLACE
Suppose that several directories on drive C contain different versions of a file named
PHONES.CLI, which
contains client names and phone numbers. To replace all of these files with the latest version of
the
PHONES.CLI file from the disk in drive A, type the following command:
Suppose you want to add new printer device drivers to a directory on drive C named TOOLS,
which
already contains several printer device-driver files for a word processor. To do this, type the
following
command:
This command searches the current directory on drive A for any files that have the extension
.PRD and then
adds these files to the TOOLS directory on drive C. Because the /A switch is included,
REPLACE adds
only those files from drive A that do not exist on drive C.
MEM
Getting general program and memory information
Suppose your system has both expanded memory and extended memory. To display a summary
of your
system's total memory conventional, expanded, extended, and upper and to display a list of
programs
currently loaded into memory, type the following command:
mem /classify
MEMMAKER
To run MemMaker in batch mode and to direct it not to reserve any upper memory for Windows
translation
buffers, use the following command:
To have MemMaker restore your previous system configuration, use the following command:
memmaker /undo
Suppose you use a disk-compression program. Your startup disk is drive C, but after the
compression
driver starts, drive C becomes your main compressed drive. Your startup files are now on drive
D. Because
of this drive-letter swapping, you would start MemMaker by using the following command:
DOS COMMAND EXAMPLES
12
memmaker /swap:d
This command specifies that the current drive D was originally the startup drive and contains
your
CONFIG.SYS and AUTOEXEC.BAT files.
Note: You do not need to use the /SWAP switch if you are using Microsoft DoubleSpace disk
compression
or the Stacker 2.0 disk-compression program.