ScanDisk

This command syntax controls Windows ScanDisk. For more information about this utility, see Chapter 20, "Disks and File Systems."

Note

At the command prompt (for example, when you use F8 to start only the command prompt), you can use scandisk with the same switches to run the MS-DOS – based equivalent for this command. At the command prompt, type scandisk /? for more information.

Syntax

scandskw [drive:] [/A] [/N] [/P]
scandisk drive:\dblspace.nnn
scandisk drive:\drvspace.nnn

Parameters

drive:

Specifies one or more drives to be checked.

/A or /All

Checks all local, nonremovable hard disk drives.

/N or /NonInteractive

Starts and closes ScanDisk automatically. However, this switch does not prevent ScanDisk from stopping to report errors found on the drive.

/p or /PREVIEW

Runs ScanDisk in Preview mode, where it reports and seems to correct errors that it finds, but it does not actually write changes to the disk.

Important When running scandskw in Preview mode, it appears as though ScanDisk is fixing errors, but it is not. Also, notice that unlike other settings in ScanDisk, the /PREVIEW switch is not saved in the Registry, so the next time you run ScanDisk, it is no longer in Preview mode.

To determine whether ScanDisk is running in Preview mode, look for the tag "(Preview)" in the caption of the main ScanDisk window.

dblspace.nnn or drvspace.nnn

Checks the specified unmounted DoubleSpace or DriveSpace compressed volume file, where nnn is the filename extension for the hidden host file.

The following table describes the codes provided when ScanDisk finished running.

Exit code

Description

0x00

Drive checked, no errors found

0x01

Errors found, all fixed

0xFA

Check could not start — cannot load or find DSKMAINT.DLL

0xFB

Check could not start — insufficient memory

0xFC

Errors found, but at least some were not fixed

0xFD

At least one drive could not be checked

0xFE

Check was canceled

0xFF

Check was terminated because of an error


You can capture the exit code in a batch file to define an action to take in the event of particular exit code. For example:


start /w scandksw c: d: /n
if errorlevel exitcode goto command
...

In this sample, start /w forces the batch file to stop and wait for scandskw to finish (otherwise, because it is a Windows-based program, the batch file would continue as soon as scandskw had been launched). Also in this example, if the actual exit code is greater than or equal to the exit code specified by exitcode, the batch file runs the specified command; otherwise, it continues to the next line in the batch file. The goto command entry could specify any command you want.