• No results found

DOS COMMAND EXAMPLES. TIME To set your computer's clock to 1:36 P.M., use either of the following commands:

N/A
N/A
Protected

Academic year: 2021

Share "DOS COMMAND EXAMPLES. TIME To set your computer's clock to 1:36 P.M., use either of the following commands:"

Copied!
12
0
0

Loading.... (view fulltext now)

Full text

(1)

DIR

Suppose you want to display all files and directories in a directory, including hidden or system files. To specify this display, type the following command:

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 mm-dd-yy parameter. mm 1 through 12 dd 1 through 31 yy 80 through 99 or 1980 through 2099

TIME

To set your computer's clock to 1:36 P.M., use either of the following commands:

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

(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:

prompt time is: $t$_date is: $d

DISKCOMP

If your system has only one floppy disk drive, drive A, and you want to compare two disks, type the 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:

copy memo.doc letter.doc /a

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:

copy note.txt mynotes /y

(3)

To copy a file named ROBIN.TYP from the current drive and directory to an existing directory named BIRDS that is located on drive C, type the following command:

copy robin.typ c:\birds

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:

copy mar89.rpt + apr89.rpt + may89.rpt report

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:

copy report + mar89.rpt + apr89.rpt + may89.rpt

You can also combine several files into one by using wildcards, as the following example shows:

copy *.txt combin.doc

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:

copy /b *.exe combin.exe

This prevents MS-DOS from treating CTRL+Z as an end-of-file character.

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.

copy *.txt + *.ref *.doc

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:

copy *.txt + *.ref combin.doc

Copying information from the keyboard

(4)

copy con output.txt

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:

copy con lpt1

REN

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:

ren *.txt *.doc

To rename a file named CHAP10 (on drive B) to PART10, type the following command:

ren b:chap10 part10

The newly renamed file PART10 remains on drive B.

DEL

To delete the CAT.TMP file from the TEST directory on drive C, you can use either of the following commands:

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 c:\*.bat /all

(5)

The following command loads the memory-resident portion of the UNDELETE program into memory, creates a hidden directory named SENTRY, and specifies that UNDELETE move files you delete on drive C to that directory:

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

(6)

If you are working on drive D and you want to copy all files in the \PUBLIC\JONES and \PUBLIC\LEWIS directories on drive C to the root directory on drive D, type the following commands:

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

MS-DOS should display only the "." and ".." symbols.

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:

tree c:\ /f | more

To print the same list that the previous example displayed, type the following command:

(7)

MOVE

Suppose C:\LETTERS is a directory. To move the files ED.TXT and SIGRID.TXT from the current directory to the LETTERS directory on drive C, type the following at the command prompt:

move ed.txt,sigrid.txt c:\letters

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:

move bill.txt c:\letters\ann.txt

To rename the THISYEAR directory on drive C to LASTYEAR, type the following at the command prompt:

move c:\thisyear c:\last year

DELTREE

To delete the TEMP directory on drive C, including all files and subdirectories of the TEMP directory, 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:

CHKDSK pauses and displays messages if it encounters errors.

To redirect the output of CHKDSK to a file named STATUS, type the following command:

chkdsk a: > status

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.

(8)

To check both drive C and drive E, type the following:

scandisk c: e:

To check all your drives, type the following:

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:

defrag c: /f /sd- /skiphigh

This example fully optimizes drive C, but slows DEFRAG

MSAV

To start MSAV using a black and white color scheme, and to specify that MSAV check all drives except drives A and B, 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

(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:

vsafe /1- /7+ /At

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:

vsafe /1- /7+ /At

MSD

Starting the MSD program

If you wanted to examine some of the technical information about your computer before calling Microsoft Product Support Services, you would start the MSD program by typing the following at the command prompt:

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

(10)

ATTRIB

To display the attributes of a file named NEWS86 located on the current drive, type the following command:

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

The following example uses the /D: and /V switches:

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.

(11)

You can create a batch program to perform XCOPY operations and use the batch IF command to process 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:

replace a:\phones.cli c:\ /s

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:

replace a:*.prd c:\tools /a

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:

memmaker /batch /w:0,0

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:

(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.

References

Related documents

In search theory outside the middleman literature, Butters (1977, p.466) says “A single homogeneous good is being traded for money,” while Burdett-Judd (1983, pp.955,960) say

If the roll is equal to or higher then the model's shooting skill then it hits and wounds as described in close combat.. If the roll was lower then the model's shooting skill then

While on his sea voyage, Darwin observed that various living forms share similarities in their structure and behaviour among themselves and also with the life forms that have

Public awareness campaigns of nonnative fish impacts should target high school educated, canal bank anglers while mercury advisories should be directed at canal bank anglers,

A review was done in the art therapy, spirituality and psychology integration, and creation theology literature to look at existing research that answers this question.. A lack

Compared to greater Pakistan, the FATA is suffering from lower levels of investment in health capital, education and economic development?. All of these factors contribute to

He had learned the basis of the bebop style, which influenced the new jazz styles; the classical approach from the traditional music schools; and different approaches to playing

Activation maps (left side) and beta-estimates (right side) for areas that showed a differential activation as a function of both task (absorption vs. analytical) and video