How to Automate Chkdsk

This article has been archived. It is offered "as is" and will no longer be updated.
Summary
Chkdsk is a native Windows NT tool that can determine the extent of fileand file system corruption. If Chkdsk is to run in write-mode to attempt toremedy corruption, in most cases, there will be locked files and itrequires restarting to have exclusive access to the partition orpartitions. This process can be automated and requires no userintervention. Usually, a user needs to press "y" to schedule Chkdsk to runin write-mode on the next restart; however, this process can be automatedas follows:

Create a batch file and then disseminate it to the preferred system orsystems:
   @echo off   echo y|chkdsk [target drive, i.e. D:] /f/r   rem sleep 3600   rem c:\utils\shutdown.exe /l /r /y /t:6				
The last two lines are optional. Sleep.exe and Shutdown.exe are from theMicrosoft Windows NT Server 4.0 Resource Kit. "Sleep 3600" causes the system to wait for 60 minutes before proceeding to the next line in the batch file. Shutdown.exe is then called to shut down and restart the target system. If Shutdown.exe is not called, and the drive could not be locked for exclusive use, Chkdsk runs the next time you manually restart the target system.

In those cases where you would like Chkdsk, or the above batch file, to bescheduled to run on specific days or times, AT Scheduler (command-lineinterface) or WinAT Scheduler (GUI-based interface that has addedfunctionality) can be used. You can find WinAT in the Microsoft Windows NT Server 4.0 Resource Kit.
More information
For additional information about Shutdown.exe, please see the followingarticle in the Microsoft Knowledge Base:
158388Useful Resource Kit Utilities for Domain Administrators
chkdsk automate script nt 4.0 batchfile at task scheduler
Properties

Article ID: 197527 - Last Review: 12/05/2015 10:01:27 - Revision: 3.0

Microsoft Windows NT Server 3.51, Microsoft Windows NT Server 4.0 Standard Edition, Microsoft Windows NT Workstation 3.51, Microsoft Windows NT Workstation 4.0 Developer Edition

  • kbnosurvey kbarchive kbinfo KB197527
Feedback