Working from a Command Prompt

Tips Part 6

What to do when you are confronted with a command (DOS) prompt

Back Next

Contents

Commands in DOS and Windows 3.x - 9x Drive and Folder Navigation
Commands specific to Windows NT/2000/XP DOS Commands in brief (table)
Drives, Folders, and Directories - definitions DOS Commands in detail
The Command Prompt - what it looks like DOS and Windows NET commands
The Command Interpreter

Jump to a Command - click here


Knowledge of DOS commands is very useful

Few Windows users issue commands from the command prompt anymore, but there may be times when you have no choice. Knowledge of some DOS commands is useful - I would say essential, if you call yourself a computer technician.

For example, you will likely be confronted with a command prompt (see below), if you boot your machine off a floppy or CD, if Windows (or any OS) refuses to run, or for various other reasons. Windows is said to be running in DOS mode if you have just a command prompt (that is, no fancy windows, icons, mouse pointer, etc).

DOS is an acronym for Disk Operating System. It was originally developed when the human interface with a computer was text-based. DOS, like all computer operating systems, tells the machine how to run itself. For the most part, it does not use icons, menus, or other graphical displays to help the user (you) understand what it is doing. You tell DOS what to do by typing words, letters, and symbols at the command prompt. Commands are not executed (carried out, or performed) until you press the Enter key.

Back to Contents

Drive vs Directory (or Folder)

Note: A Folder is the same thing as a Directory

A drive is a physical piece of hardware. Examples include your A: (floppy) drive and your C: (hard disk) drive. The disk in your A: drive contains the A: directory (or folder), hence A: is both a drive and a directory. Whatever disk happens to be in the drive is the A: drive. Your C: drive contains the C: directory, and so C: is both a drive and directory as well. A: and C: are the root directories of those drives, meaning they are the "top" of the directory structure - from there you go "down" into subdirectories. Consider this example:

In the left window, you see C: at the top, with lines going downwards to other (sub-) directories: best, Mouse, My Documents, etc. The Temp folder is open, so you see the file(s) in the Temp folder on the right.

Back to Contents

The command prompt

The command prompt usually consists of a drive letter followed by a colon, a backslash, and the right angle bracket, like this: A:\> or C:\>. It may look like A> or C>, or it may include the date and time, or there may be no prompt at all, just a blinking cursor (which is usually the sign of a sick computer, but not always). If you change to a subdirectory, the name of that directory should appear as part of the prompt, e.g. C:\WINDOWS\>. If it does not, type the following at whatever prompt you have:

PROMPT=$P$G

To see your command prompt (within Windows), click Start > Programs > MSDOS prompt. You will see a window open, looking something like this:

DOSbox

A DOS prompt in a window, while running Windows, is commonly referred to as a "DOS box". In true DOS mode, Windows is not running, and your entire screen is black, with white text.

The Command Interpreter

The Command Interpreter is a file called COMMAND.COM in DOS and Windows 3.x - 9x. In Windows NT/2000/XP the command interpreter is a file called CMD.EXE.

It is what creates the user interface: the command prompt itself. A:\> or C:\> (or D:\> or E:\> etc.) is the standard DOS command prompt. It shows you the current drive and directory, which tells you where you are in the directory structure.

What you type at the command prompt is translated by the command interpreter into instructions the machine understands, and then executed. Some DOS commands are internal, which means they are part of COMMAND.COM (or CMD.EXE); others are external, which means they are separate files. Look in your C:\DOS directory (or for Windows, try C:\WINDOWS\COMMAND) - you will not see any file called COPY.EXE, because it is internal. You will, however, see files called FORMAT.COM, ATTRIB.EXE, etc., because they are external. The files for each external command must be present, or you cannot use them.

Back to Contents

Changing from one drive to another

You can change the root directory at any time by typing its letter and a colon. For example, if you booted your computer from the A: drive and want to change to the C: drive, type C: and press Enter. If you are at a C: prompt and want to switch to A:, type A: and press Enter (if there is no disk in drive A: you will get an error message). The same goes for any other drive, D:, E:, F:, etc.

By convention, names of directories, drives, and commands are written in capitals. They do not have to be in capitals when you type them at the command prompt. DOS and Windows 3.x can't tell the difference between upper- and lower-case; Windows 9x and later can tell, but it makes no difference in this situation.


For the next section, some conventions must be understood. See the examples.

[ ] enclose options; the brackets are not typed
< > enclose drive, directory, and file names; the brackets are not typed
| separates two or more options within [ ]; if there are no brackets, one of the options must be used, e.g. ON|OFF|AUTO - you must follow the command with one of ON, or OFF, or AUTO.
/ precedes a switch; type it

Back to Contents

In Brief:

If the meaning is quite obvious, it is omitted. Click a command for more detailed info. * indicates external commands.

Command Meaning Use it to
ATTRIB* attribute(s) display/change file attributes
CD change directory change to another directory
CHKDSK* check disk display hard drive info
CLS clear screen clear the screen
COPY   copy files
DATE   set/check the system date
DEFRAG* defragment defragment the hard drive
DEL delete delete files
DELTREE* delete tree (directory) delete whole directories
DIR directory list files and subdirectories
DISKCOPY* copy disk(s) copy disks
EDIT*   edit/view plain text files
FDISK* fixed disk create partitions
FORMAT*   format drives (hard or floppy)
HELP*   get help for DOS commands
LABEL*   view/change a disk label
MD make directory create a directory
MEM* memory display memory usage
MORE*   view long files
RD remove directory remove a directory
REPLACE*   replace/update files
SCANDISK*   test a disk for errors
SYS* system transfer system files
TIME   set/check the system time
TYPE   type a file on-screen
UNDELETE*   recover deleted files
UNFORMAT*   undo a FORMAT
VER version display DOS version no.
XCOPY*   copy files/directories/subdirs

* indicates external commands


Back to Contents

In Detail:

For the sake of brevity, and so as not to confuse the reader, I have not included every possible switch and option for each command. For additional information on any command, type HELP <command name> at your C:\ prompt, or click on Start > Help in Windows.

It is assumed, unless otherwise indicated, that all commands are typed at the C:\> prompt.


ATTRIB: display/change file attributes

All files have attributes, or properties. This command is most useful for viewing or changing the hidden and read-only attributes. It also allows you to "see" hidden files, which do not appear when you use the DIR command (see below).

ATTRIB [-R|+R] [-H|+H]

+ sets the attribute
- clears the attribute
R makes a file(s) read-only or readable and writable (i.e. you can modify/delete it)
H makes a file hidden (or not)

Typing ATTRIB alone displays the attributes of all files in the current directory. It is possible to hide a directory (ATTRIB +h <directory name>), but hidden directories do not appear when you type ATTRIB. If you want to access or delete a hidden directory, or change its attributes, you must know its name. Unlike DOS, hidden directories are visible to Windows FileManager and Explorer.

Example

ATTRIB D:\PIX\BABES.JPG +R +H

After issuing the above command, the file BABES.JPGin the folder PIX on drive D: is hidden and read-only.

Back to Contents

CD: change to another directory

CD\ changes to the root directory (that is, the highest level, like C:\> or A:\>)
CD.. changes to the next directory up
CD <drive><directory> changes to a specific drive and/or directory

Examples - assuming you are starting at C:\>

CD WINDOWS - changes to your WINDOWS directory; the command prompt now looks like:

C:\WINDOWS\>

CD SYSTEM - changes to the SYSTEM subdirectory of the WINDOWS directory; the command prompt now looks like:

C:\WINDOWS\SYSTEM\>

CD.. changes back up to the WINDOWS directory from the SYSTEM directory

CD A:\LETTERS - you get the idea


CHKDSK: display hard drive info

Use it at the C:\> prompt. CHKDSK displays the total amount of space on your C: drive, how much is being used and how much is free, the total amount of conventional memory and how much is free. Starting with DOS 6.00, if you use CHKDSK, you get a message recommending that you use SCANDISK instead (see below). There is one switch:

/F fixes errors, sort of - you may find files with the extension .CHK afterwards (but they may have been created by SCANDISK)

CHKDSK with the /F switch is not very efficient; use SCANDISK and DEFRAG to fix hard drive problems.

Back to Contents

CLS: clear the screen

There are no switches or options. CLS gives you a blank screen, with the command prompt in the upper left corner.


COPY: copy files

COPY {<drive><directory><filename.ext>} {<drive><directory><filename.ext>}

The first group are the source drive/dir/filename, the second are the destination drive/dir/filename. If the destination filename is not specified, the same name is used for the copied file; you can specify a different name. This is useful for making backups before modifying important files.

Wildcards are * and ? in file names; * stands for any number of characters, ? for any single character (see below). If the file(s) you are copying are in the current directory, the directory need not be specified.

Examples

COPY C:\WINDOWS\WIN.INI A:\WIN.OLD - copies and renames WIN.INI to A:\WIN.OLD

COPY C:\WINDOWS\SYSTEM\*.DLL A: - copies all files with the .DLL extension to A:

COPY L*.* A:\BACKUP - copies all files in the current dir starting with the letter L to A:\BACKUP

Note: if there is no dir on A: called BACKUP, all the files are concatenated into a new file called BACKUP; also, if the destination does not have enough space to hold the files being copied, COPY will terminate with an error message - be sure of your source and destination! Windows FileManager and Explorer are more forgiving: they prompt you to insert another floppy disk when one gets full, and continue copying. They will, however, concatenate files if the destination dir does not exist, as in DOS. This will not happen if you use the drag and drop method of file copying (see Tips Part 3, or look up "copying" in Windows 3.x FileManager's Help menu, or "drag and drop" in Windows 9x and later).

Another note about DOS file names: DOS can only understand file and directory names up to eight characters long, plus an extension of up to three characters, preceded by a period. The following characters cannot be used: * ? / \ ; : and a space. This is a limitation of the pre-Windows 9x FAT (File Allocation Table; see DEL). An extension is optional for both files and directories. This is known as the 8+3 or 8.3 file name convention. Even under Windows, if you are in DOS mode, file names will be truncated if they exceed the 8.3 standard. For example, a file which Windows 9x reports as being called Lettertomom.doc will appear as LETTER~1.DOC. The seventh character will be a ~, and the eighth will be a number.

COPY C:\MYWORK\*.X?? C:\TEMP copies all files with an extension starting with X to C:\TEMP

COPY A:\*.* C:\TEMP - copies all files on A: to C:\TEMP;

A short cut for *.* is just a period:

COPY A:. C:\TEMP - does exactly the same thing as COPY A:\*.* C:\TEMP

You can save yourself some typing by switching to the dir containing the files you want to copy, or where you want them to end up. For example, switch to the MYWORK dir and type:

COPY *.X?? *.BAK - copies all files with an extension starting with X to files with the extension .BAK (in the same dir); otherwise they have the same name (what comes before the dot); the original files are not changed or affected in any way - you now have copies of them with a different extension (.BAK)

Back to Contents

DATE: set/check the system date

When you type DATE, the computer displays what it thinks is the date. If you do not wish to change it, just press Enter. If you change it, use the same format as the displayed date. You can change the format, but it is a complicated procedure.

Note: The date (and time) reported by a computer can change due to a crash, power failure or surge, or if the internal battery runs low (either it needs to be replaced or the machine was left unplugged for a long time).

Another note: DOS 6.22 does not seem to have a problem with the year 2000. I had it running on a machine from Dec. 1999 to Feb. 2000, with no ill effects. I have not tested earlier versions. Windows 3.x, however, cannot handle years beyond 1999.


DEFRAG: defragment the hard drive

DEFRAG <drive>

DEFRAG cleans up hard drives (see below about floppy/zip disks). Files can become fragmented; that is, a large file may not be stored on the drive as a contiguous block of data. This makes retrieving, saving, and copying it take longer because it has to be re-assembled when you call it up or copy it, and taken apart when you save it. As a general rule, a hard drive should be defragmented at least once a month, more if the machine is under heavy use.

You should also run DEFRAG before installing new software, and after deleting a large number of files or uninstalling a program.

Defragmenting floppy or zip disks is a waste of time. It is much faster to do the following, if you think you have a fragmented floppy disk:

1. Copy everything on the disk to a temporary directory on your hard drive.
2. Re-copy it back to a blank floppy. You can use the same disk, but re-format it first (see FORMAT).

COPY and XCOPY copy files as contiguous blocks, thus re-assembling them. DISKCOPY does not (see COPY, XCOPY, and DISKCOPY).

Back to Contents

DEL: delete files

DEL <drive><directory><filename.ext>

DEL only deletes files with the hidden and read-only attributes off. It does not delete directories, or hidden files or read-only files (i.e. files with those attributes set).

The wild cards * and ? apply, and are used just as with the COPY command; likewise the . (same as *.*).

Examples

DEL. - deletes all files in the current dir (but not subdirs, hidden files, or read-only files)

DEL A:\*.DOC - deletes all files in A: with the .DOC extension, etc.

Note: Everyone, at some time or another, deletes files that they did not want to delete. Be sure to read about UNDELETE (below). Deleted files can often be recovered with UNDELETE or some other rescue utility, but the chances of recovery grow less with time and disk activity. The reason is because DEL does not really delete files, nor does Windows 3.x FileManager.

There is a certain amount of space reserved on every disk (hard disk or floppy) for directory names and file names. A 1.44M floppy disk actually has 2M of space, but just over one quarter of it is used for formatting information and the file allocation tables (FAT).

The FAT is kind of like the disk's Table of Contents and Index combined. A filename entry has a 0 (zero) as the first character if that entry is empty. Programs like FileManager and Explorer, and the DIR command, ignore these entries. When you use the DEL command, all it does is change the first character of that filename entry in the FAT to a 0, so it will henceforth be ignored. The rest of the filename is still there, and so is the file on the disk, until they are overwritten by another filename or file.

They might not both be overwritten at the same time - the filename might still be in the FAT (minus the first character), but the space occupied by the file may or may not be in use by another file, or it may be partly in use. For more nerdy details, see UNDELETE.

Another note: When you delete files in Windows 9x and later, they are not deleted at all, but sent to a certain place on the hard disk called the Recycle Bin. The Recycle Bin is only a certain size, however; when it gets full, the oldest files get kicked out to make room for more deleted files. After that, they are lost for good, although there are utilities which claim to be able to retrieve such files (I have never tried any). The same rules apply as above: the more recently you deleted a file, the better your chance of getting it back.

Back to Contents

DELTREE: delete whole directories, as well as their subdirectories

DELTREE <drive><directory>

This command is potentially dangerous, so use with caution: it deletes a directory and all its files, as well as all subdirectories and their files. It is useful in certain circumstances, such as when you want to get rid of a program or files you no longer want, or if you want to remove or re-install a program that has no uninstall routine.

For a safer alternative to DELTREE, see RD below.

Example

DELTREE C:\WINDOWS

You could use this (as I often have) when Windows becomes hopelessly corrupt and has to be re-installed. If C: is the current directory (in the example above), you can omit C:\, and just type DELTREE WINDOWS.

Note: You will be asked for confirmation before the deletion proceeds.

Back to Contents

DIR: list files, directories, and subdirectories

DIR <drive><directory> [/O] [/P] [/S] [/W]

An extremely useful command, DIR tells you what is on a disk, drive, or directory. Wild cards work the same as with COPY and DEL.

/O - lists files and directories in alphabetical order, directories first
/P - pauses at every screen full; press any key to see the next screen
/S - displays all subdirectories and their contents
/W - displays files and directories in wide format, but omits the dates, times, and sizes

Examples

DIR - by itself, shows the contents of the current drive or directory - listed in random order, as far as I can tell

DIR *.DOC - lists all files in the current dir (C:, I am assuming) with the .DOC extension

DIR /O/P - lists all files and dirs on C: in order, pausing at every screen full

DIR /O/P/W - lists all files and dirs on C: in order, wide format, pausing at every screen full

DIR /O/P/S - lists all files, dirs, and subdirs on C: in order, pausing at every screen full

To see just the contents of a subdirectory, switch to it using the CD command (see above).

A useful thing to have is an "image" of your hard drive - a listing of all directories, subdirectories, and files, and where they are. You can easily create one and save it as a text file using the DIR command and the redirection symbol >. At your C: prompt, type the following:

DIR /O/S > DIR-C.TXT

After doing this, you will see a new file on your C: drive called DIR-C.TXT. It is a plain text file, which lists the entire contents of your C: drive. The > DIR-C.TXT part tells DOS to send the output of the command DIR /O/S to a file called DIR-C.TXT, instead of sending it to your screen (the default). If there are a lot of files on the drive, it may take some time for the operation to complete.

Back to Contents

DISKCOPY: copy disks (floppies ONLY)

DISKCOPY <source drive><destination drive> [/V]

/V - verifies that the destination disk is identical to the source disk (making the copying process significantly slower)

This makes an exact duplicate of a disk. If the source disk is a bootable disk, the destination disk will be as well; this command copies everything on the source disk, including hidden and system files. You cannot use it to copy a hard disk, only floppies.

Examples

DISKCOPY A: A: - copies a disk in drive A: to another disk in drive A:. You will be asked to insert the source disk, and then the destination disk. Depending on what version of DOS you have, you may also be asked if you wish to make another copy of the same disk, or a copy of a different disk.

DISKCOPY A: B: - if you have two floppy drives, this copies the disk in A: to the disk in B:

Notes: Both disks must be the same size, which is not much of a concern these days (does anyone still have and use 720Kb, or 5 1/4" floppies?).

Do not use DISKCOPY to copy disks that have fragmented files: the files on the destination disk will also be fragmented; use COPY or XCOPY. Remember, DISKCOPY makes an exact duplicate of the source disk. I have even seen DISKCOPY copy Bad Block flags: parts of the source disk were physically damaged, and DISKCOPY marked, as bad, the same blocks on the destination disk (although they were not really bad).

Back to Contents

EDIT: edit/view plain text files

EDIT <drive><directory><filename>

EDIT is a plain text editor, like Windows NotePad. You can use it to view and edit any files with the extensions .BAT, .INF, .INI, .TXT, and CONFIG.SYS. You do not need to specify a filename. You can access the menus by pressing the Alt key and using the arrow keys to navigate; or, Alt+F opens the File menu, Alt+E opens the edit menu, etc.

Examples

EDIT - starts EDIT with a blank document.

EDIT AUTOEXEC.BAT - starts EDIT and loads AUTOEXEC.BAT for you to view or edit.

Note: Be careful with files having the extensions .BAT, .CMD, .INF, .INI, .PIF, and .SYS, especially if you are a novice. Looking at them is harmless, but making changes to them is dangerous, unless you know what you are doing. They are system configuration files, which tell your computer and various programs how to run. Leave them alone. If you just want to look at such files, use TYPE instead (see TYPE).


FDISK: create drives/partitions

A complex and DANGEROUS command. See Tips 9: Hard disks and partitions for details.


FORMAT: format disks/drives (hard or floppy). WARNING: THIS COMMAND CAN BE DANGEROUS.

For more detail, see Tips 9: Hard disks and partitions

FORMAT <drive> [/B] [/Q] [/S]

<drive> - the drive or floppy disk you want to format (e.g. A:, C:, D:, etc.); see below.

/B - reserves space on a (floppy) disk for the system files, in case at some time you might want to make the disk bootable (see SYS, below). This switch is only needed if you are using a version of DOS earlier than 6.x. DOS 6.x reserves space for the system files by default.

/Q - performs a "quick" format (i.e., wipes out the FAT without actually scanning the whole disk/drive). For an explanation of the FAT, see DELETE and UNDELETE.

/S - formats the disk/drive and copies the system files to it; this makes the disk/drive bootable, whether it is a hard drive or floppy (see SYS).

Example:

FORMAT A: /S - formats a floppy disk in drive A: and makes it bootable

Note: This command will erase all data on a drive; BE CAREFUL! An unformatted disk/drive is kind of like a blank sheet of paper; after formatting, it is kind of like a sheet of paper with lines and margins on it. No operating system or program can use or access an unformatted disk/drive.

Back to Contents

HELP: get help for DOS commands

HELP <command name>

HELP is only available in DOS 5.x to 6.22.

If you type HELP by itself at the command prompt, you get the introductory screen, which is a list of every single DOS command. Use the arrow keys to move up and down, and TAB to switch columns (DOS 6.x).

You can go directly to help on any command by typing HELP <command name>

Example

HELP COPY - will tell you more than you wanted to know about the COPY command.

Note: HELP for DOS 5.x is not nearly as comprehensive as for 6.x. You can also usually get help, in a rather terse format, for many executable files (having the extension .EXE or .COM), by typing the name of the executable followed by /? or /H. Try it: go to your C: prompt and type WIN /?, or COPY /?, and look at your options. If you have downloaded or "borrowed" a program you know nothing about, quite often this switch works, and might give you some useful information. Again, just type <program name> /? or /H. At worst, you will get an error message.


LABEL: view/change a disk label

LABEL  <drive> <label>

A label is really only a way of naming a disk or drive, so to speak. The full expression is volume label, and only the people at Microsoft can tell you why. In other words, the name of a disk or drive is its volume label. When you use the DIR command, the first thing you see is "Volume in drive <drive> is <volume label>". You can use the LABEL command to change the volume label; there is another command which simply let's you see the volume label, which is not otherwise discussed in this document: type VOL at the C: prompt ( or A:, or D:, or E: etc.).

Back to Contents

MD: create a directory

MD <directory name>

Fairly self-explanatory. You can use this command from any place in the directory structure to create new directory: from A: or C: or any subdirectory. There is (allegedly) no limit to the number of subdirectories you can create. You could, for example, create the following:

C:\SYSTEM\BACKUP\MYSYSTEM\TODAY\WIN31\STUFF\DLL\NOTUSED etc etc

To create subdirectories, you first have to switch to the directory in which you wish to create them (it). In the example above, you would first use MD to create the SYSTEM dir, then use CD SYSTEM to switch to that dir; then type MD BACKUP, CD BACKUP, MD MYSYSTEM, CD MYSYSTEM, etc.


MEM: display memory usage

MEM [/C] [/P]

MEM - by itself displays a summary of memory usage (how much is in use and how much is free)

/C - lists each program currently in memory and how much memory they are using

/P - pauses after each screen full of information

When using this command, type either MEM alone, or MEM /C/P. If you use the /C switch, there will probably be more than one screen full of information.

Back to Contents

MORE: view long files

An odd command, but useful, especially with the TYPE command. It requires the use of the redirection symbols, <, >, and | . Almost useless by itself, it is a "filter" by which you can view the output of commands that take up more than one screen full of information and would otherwise scroll by, and you would only be able to see the very end of. See DIR /P (above), and TYPE (below).

You can use MORE alone to view long text files with the redirection symbol < :

MORE < DIR-C.TXT - this is exactly the same as typing TYPE DIR-C.TXT | MORE

See TYPE.


RD: remove a directory

RD <directory>

A safer alternative to DELTREE, RD removes (deletes) a directory. If you try to delete a directory that still has files or subdirectories in it, you will get an error message: RD will only delete an empty directory. Delete all files and subdirectories first, or use DELTREE if you are sure you want to delete that directory and all its contents (see DELTREE).

Back to Contents

REPLACE: replace/update files

REPLACE {<drive><directory><filename(s)>} {<drive><directory><filename(s)>} [/A] [/U]

The first group in the {} brackets is the source; the second is the destination (see COPY).

/A - adds new files
/U - overwrites files on the destination drive that have dates older than those on the source drive

If you are using DOS 3.30 - 6.x, you have the REPLACE command, which is a quick way to make backups (this command does not exist in Windows 95 and later). They are not compressed or archived, and can be retrieved or viewed without hassle. Using EDIT or Windows NotePad, create a text file with the following lines (upper-case is conventional in files like this, but not necessary):

@ECHO OFF
CLS
REPLACE {<drive><directory><filename.ext>} {<drive><directory><filename.ext>} /A
REPLACE {<drive><directory><filename.ext>} {<drive><directory><filename.ext>} /U

Save it with an appropriate name, such as BACKUP.BAT, but whatever name you choose, the extension must be .BAT. Incidentally, if you do this, congratulate yourself: you just wrote a computer program; modest, perhaps, but a program nonetheless.

The first group in the curly brackets is the source, the second is the destination; you must supply both of them, but Wild Cards will work too (see the example below). The /A switch adds new files to the destination (created since the last time you ran BACKUP.BAT), and the /U switch updates existing files (files with dates more recent than those in the destination). The /A and /U switches cannot be used on the same line, hence REPLACE must be listed twice, once with each switch.

Example

Assuming you want to backup to the A: drive, and your source files are in a directory called C:\MYWORK, your BACKUP.BAT file should read:

@ECHO OFF
CLS
REPLACE C:\MYWORK\*.* A: /A
REPLACE C:\MYWORK\*.* A: /U

Note: remember, wild cards work with REPLACE. For example, if you only want to backup files with the .DOC extension, the source directory is then C:\MYWORK\*.DOC.

Back to Contents

SCANDISK: test a disk for errors

SCANDISK tests a disk or drive for physical errors, and fixes them if possible. If SCANDISK finds damaged areas, it tries to recover whatever data it can, and marks the damaged areas as bad; then no program will attempt store data there.

SCANDISK <drive> [/AUTOFIX] [/NOSAVE]

/AUTOFIX - repairs errors without prompting you to confirm the operation

/NOSAVE - does not save lost clusters as files (lost clusters are areas of the drive that are reported as being in use by files, but actually are not - they may or may not contain useful/lost data). This switch must be used with AUTOFIX

If you type SCANDISK alone, it automatically starts examining the disk/drive it is on. If you run it from your C: drive and wish to scan a floppy, type SCANDISK A:. If you run it from a floppy and wish to scan your C: drive, type SCANDISK C:.

Note: As with DEFRAG, running SCANDISK once in a while is a good idea. If your hard drive suddenly develops bad areas, and you see more and more of them each time you run SCANDISK, your hard drive is dying. Backup your data immediately and go shopping for a new hard drive. It happens. The average life of a hard drive is about 3 years under heavy use, although newer drives are (allegedly) more durable.


SYS: transfer system files (i.e., make a disk/drive bootable to a DOS prompt)

SYS <drive>

This command makes a floppy disk or hard disk bootable. If the disk is unformatted, FORMAT /S does the same thing; if the disk/drive is already formatted, use SYS.

Example

SYS A: - makes a formatted floppy in drive A: bootable

See also FORMAT /S, above.

Back to Contents

TIME: set/check the system time

Much like DATE, typing TIME makes the machine display what time it thinks it is. To accept the displayed time, press Enter; to change it, type it in, using the same format as the displayed time.


TYPE: display a file on-screen

TYPE <drive><directory><filename.ext> [| MORE]

| MORE - causes TYPE to pause after each screen full of text; note the | (pipe), not a / (slash).

Examples

TYPE AUTOEXEC.BAT - displays the file AUTOEXEC.BAT on screen

TYPE DIR-C.TXT | MORE - displays the file DIR-C.TXT on screen, pausing at each screen full (see DIR)

Note: TYPE simply displays a file on-screen; you cannot change it, only look at it. This only works with plain text files, i.e., any files with the extensions .BAT, .TXT, and most with the extension .INF and .INI; your CONFIG.SYS file is also plain text. You can try using it to display other kinds of files, but you will probably see a screen full of garbage, if anything.

Back to Contents

UNDELETE: recover deleted files

UNDELETE <drive><directory><filename.ext> [/LIST] [/ALL]

/LIST - just lists recoverable files

/ALL - undeletes all recoverable files without asking

If you know the name and location of a deleted file, you can specify it; otherwise UNDELETE looks for deleted files in the current directory. Wild cards are allowed (see COPY).

Note: If you use the /ALL switch, UNDELETE assigns characters for the missing first character, starting with # (see DEL for an explanation of this). If a near-duplicate name is found (say you deleted two files, called MAT.DOC and PAT.DOC), characters are assigned in this order: #%&, 0-9, A-Z. The files MAT.DOC and PAT.DOC will be recovered with the names #AT.DOC and %AT.DOC, respectively.

Examples

UNDELETE - searches the current directory for any deleted (and recoverable) files; you will be prompted to provide the first character of their names

UNDELETE C:\MYWORK\*.DOC - looks for deleted files in the MYWORK directory with the .DOC extension; again, you will be prompted to provide the first character of their names

Back to Contents

UNFORMAT: undo a FORMAT

UNFORMAT <drive>

Re-formatted disks are usually unrecoverable, but if they were formatted with the /Q switch (see FORMAT), and have not been used much, or at all, chances are that something can be recovered (but don't count on it).


VER: display DOS/Windows version information

When you type VER, the DOS version number is displayed, something like this:

MS-DOS 6.22

In Windows 9x and later, you will see something like this:

Windows 9x. [version 4.00.xxxx]

That is, 4.00 followed by four other digits. The 4.00 is Microsoft's quiet admission that Windows 95 is also Windows 4.x. There are in fact several versions of Windows 95, known to the initiated as 950, 950A, 950B 2.0, 950B 2.1, and 950B 2.5. There may also be versions I've never heard of. There are also several versions of Windows 98, and, never mind, stop yawning...


XCOPY: copy files/directories/subdirs

XCOPY {<drive><directory><filename(s)>} {<drive><directory><filename(s)>} [/E] [/S] [/V] [/H]

The first group in the {} brackets is the source; the second is the destination (see COPY).

/E - copies subdirectories, even if they are empty
/S - copies subdirectories (only those containing files, unless you also use the /E switch)
/V - verifies that the destination files are identical to the source files after copying; this slows down the copying process, but it is a good precaution
/H - copies hidden files (only available in Windows 95 and later)

The COPY command cannot copy subdirectories. You can, with XCOPY, copy the entire contents of your hard drive to another hard drive (e.g. if you buy a new one), but you might want a nerd to help you. First you have to have the new drive formatted and physically connected. The destination drive must have enough space to hold all the files you wish to copy, or XCOPY will terminate with an error message.

Examples

XCOPY C:\MYFILES\*.* A: /S /E /V - copies all files and dirs in C:\MYFILES to A: and verifies them

XCOPY C:\*.* D: /S /E /H /V - copies absolutely everything from your C: drive to your brand spanking new 100 gigabyte drive D:, even hidden and system files (remember /H is only available with Windows 95 and later)

Note: If you change other hardware in your system at the same time as the hard drive, you may need to install Windows from scratch on the new drive. You will definitely need to install Windows from scratch if you get a new motherboard (unless you want to go messing about in the Registry, which is more trouble than it's worth, and I do not recommend). After that, you can copy your data from the old drive to the new one. Any programs will have to be re-installed. Most people should not try this at home.

Back to Contents
Back Next

Copyright © Michael Ward 1999 - 2009