5. Using Common DOS Utilities
You'll find a number
of common DOS utilities on your hard drive. Most of these utilities
appear with every version of DOS, even those that Microsoft didn't
produce (such as the IBM version). For the most part, these utilities
perform maintenance tasks that you could perform in a batch file. For
example, many people had batch files for working with the DiskCopy
utility when floppy disks were popular. The following sections describe
these utilities in detail.
5.1. Comparing the Contents of Disks with the Disk Comp Utility
You can use this
utility to compare the contents of two floppy disks. Because of the way
the utility works, the two floppies must have precisely the same format
and you can't compare two newer forms of media, such as CDs.
DISKCOMP [drive1: [drive2:]]
The following list describes each of the command line arguments.
drive1:
Specifies the source drive.
drive2:
Specifies the
destination drive. If you don't specify a destination drive, the utility
assumes that you'll use one drive for the comparison and prompts you to
replace the source disk with the destination disk as needed.
5.1. Copying One Disk to Another with the Disk Copy Utility
You can use this
utility to copy the contents of one floppy disk to another floppy disk.
Because of the way the utility works, the two floppies must have
precisely the same format. This utility uses the following syntax:
DISKCOPY [drive1: [drive2:]] [/V]
The following list describes each of the command line arguments.
drive1:
Specifies the source drive.
drive2:
Specifies the
destination drive. If you don't specify a destination drive, the utility
assumes that you'll use one drive for the comparison and prompts you to
replace the source disk with the destination disk as needed.
/V
Verifies that the files copied correctly. Always use this option to ensure maximum copy reliability.
5.2. Modifying Data Files with the Edit Utility
The Edit utility is a very
useful application to know about because it works when most other
editors don't. The Edit utility is quite small, so you can place it on a
floppy if you want or a CD that contains your diagnostic software. In
addition, you don't need a graphical interface to use Edit, so it works
at the DOS prompt, the Windows recovery console, or just about anywhere
else you might need an editor. However, even with these limits, Edit
supports a robust interface for a text editor, as shown in Figure 1.
From a Server Core perspective, however, the Edit utility is best
because it has no reliance on Windows functionality, so you don't need
to worry about issues such as common dialog box usage.
As you can see, the
utility sports many of the same features as Notepad, but without the
Note-pad requirements. This utility uses the following syntax:
EDIT [/B] [/H] [/R] [/S] [/<nnn>] [/?] [file(s)]
The following list describes each of the command line arguments.
/B
Sets Edit to start in monochrome mode.
/H
Sets Edit to start with the maximum number of lines of text for your hardware. The default setup displays 25 lines of text.
/R
Loads files in read-only mode. Use this option when you want to view the file content without accidentally changing it.
/S
Forces Edit to use short filenames.
/nnn
Loads a binary file and displays the content by wrapping any long lines to the specified number of characters.
file
Specifies the name
of the file to load. You can use wildcard characters and multiple file
specifications to load multiple files. This argument must appear as the
last argument on the command line.
5.3. Formatting a Disk with the Format Utility
The Format utility
formats a drive and prepares it for use. The utility removes any
existing data from the volume you select. This section discusses the
command line version of the Format utility.
The recovery console
offers a slightly different version of this utility. You must be a
member of the Administrators group to use this utility. The utility
always displays a warning message before it formats a hard drive; you
must specifically accept the warning message content before the format
will start. This utility uses the following syntax:
FORMAT volume [/FS:file-system] [/V:label] [/Q] [/A:size] [/C] [/X]
[/P:Passes]
FORMAT volume [/V:label] [/Q] [/F:size] [/P:Passes]
FORMAT volume [/V:label] [/Q] [/T:tracks /N:sectors] [/P:Passes]
FORMAT volume [/V:label] [/Q] [/P:Passes]
FORMAT volume [/Q]
The following list describes each of the command line arguments.
The Format utility
has caused people more woe than any other utility ever created. Simply
stated, the Format utility will format your hard drive. In many cases,
you can recover files that the Format utility removes from the hard
drive using a special utility, but the process is time consuming and
error prone at best. Use this utility with extreme caution.
|
|
volume
Specifies the
drive letter, mount point, or volume name to format. Always include this
argument because the default value is the current drive.
/FS:
filesystemSpecifies the
file system to use to format the volume. You have the option of using
the FAT (older 16-bit), FAT32, or NTFS file systems when working with a
hard drive. Floppy media only accepts the FAT file system.
/V:
[ label]Specifies the
volume name. If you use this command line switch without specifying a
volume name, the Format utility prompts you for a volume name on
completion of the format.
/Q
Performs a quick
format of the media. A quick format deletes the file table and the root
directory of the media. It doesn't perform a sector-by-sector scan of
the media to locate bad sectors. You should only use this option with
known good media.
/C
Creates an NTFS
volume that the system compresses by default. Consequently, you won't
need to perform this step separately later.
/X
Forces the system to dismount the drive before formatting if necessary. Dismounting the drive closes all open handles.
/A:
sizeOverrides
the default allocation unit size for the hard drive. You can use this
feature to optimize storage for specific tasks. For example, if you plan
to store many small files, you might want to use a small allocation
size. The size argument can include 512 bytes, 1,024 bytes, 2,048 bytes,
4,096 bytes, 8,192 bytes, 16 KB, 32 KB, and 64 KB cluster sizes for
NTFS drives. You can't use compression on NTFS drives with a cluster
size larger than 4,096. A FAT- or FAT32-formatted drive can use cluster
sizes of 512 bytes, 1,024 bytes, 2,048 bytes, 4,096 bytes, 8,192 bytes,
16 KB, 32 KB, 64 KB, 128 KB, and 256 KB. You can only use the 128 KB and
256 KB options for a sector size greater than 512 bytes.
NOTE
FAT and FAT32
file systems impose a limit on the number of clusters per volume. A
FAT-formatted drive can have 65,526 or fewer clusters. A FAT32-formatted
drive can have any number of clusters between 65,526 and 4,177,918. The
Format utility stops immediately when it detects that a drive can't
meet the number of cluster requirements using the specified cluster
size.
/F:
sizeSpecifies the
size of the floppy disk to format. The default setting is 1.44 MB. You
can specify this value as 1,440, 1,440k, 1,440kb, 1.44, 1.44m, or
1.44mb. The Format utility will also format 720 KB floppies. None of the
Microsoft documentation specifies whether the utility formats 2.88 MB
floppies. Theoretically, you can also format the very old 51/4-inch
floppies with sizes of 640 KB and 1.2 MB. Use this option, whenever
possible, instead of the /T and /N command line switches.
/T:
tracksSpecifies the number of tracks per side of the disk.
/N:
sectorsSpecifies the number of sectors per track.
The format
command provides a number of exit codes that you can use when working
with batch files. The following list describes each of the exit codes.
0
The format completed successfully.
1
The format failed because you provided incorrect arguments.
4
A fatal error
occurred. For example, the utility couldn't format the drive because
the system has it locked for use. The Format utility uses this error
when the 0, 1, or 5 codes don't apply.
5
The user pressed N when the utility asked whether it should proceed with the disk format. Pressing N always stops the formatting process.
/P:
PassesZeroes every sector on the hard drive the number of times defined by Passes. The /P
command line switch makes it possible for you to erase the data on a
hard drive more completely. However, the only certain way to ensure the
data is gone is to destroy the hard drive completely and magnetically
erase the media.
5.4. Loading Older DOS Applications with the Load Fix Utility
Some older
applications don't load correctly. You'll see a "Packed file corrupt"
error message when you try to load them. The LoadFix utility modifies
the loading process for these applications so they load above the 64 KB
area of memory used for operating system needs. This utility uses the
following syntax:
LOADFIX [drive:][path]filename
The following describes the command line argument:
[drive:][path]filename Specifies the name and location of the file to modify.
5.5. Terminating a Session Using the Logoff Utility
The Logoff utility ends a
user session and logs off the user. The advantage of this utility is
that you can find it in older versions of Windows, so you can use the
same script on just about any machine. The disadvantage of this utility
is that it provides limited functionality. This utility uses the following syntax:
LOGOFF [sessionname | sessionid] [/SERVER:servername] [/V]
The following list describes each of the command line arguments.
sessionname
Defines the name
of the session that you want to log off. Older versions of the tool
don't provide this argument. The default is to log off the current
session.
sessionid
Defines the identifier of the session that you want to log off.
/SERVER:
servernameSpecifies the
server containing the user session to log off. Some documentation
implies that you need Terminal Server to use this command line switch,
but it appears to work just as well without it.
/V
Displays detailed information about the actions the system performs during the logoff cycle.