Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


Automate CHKDSK and CHKDSK /f to run multiple times

  • Please log in to reply
2 replies to this topic

#1 Mr LunchBox

Mr LunchBox

  • Members
  • 318 posts
  • Gender:Male
  • Location:California
  • Local time:09:39 PM

Posted 30 June 2009 - 02:25 AM


Lately I have been running CHKDSK /f multiple times to fix issues. At one point I ran it probably 5 to 8 times (this is still quicker than re-install of win)

I think I have a batch file that can do it but it doesnt work as I want it to.

I would like to
1> Run CHKDSK if /F is required then run it on next boot
2> Run CHKDSK /f a specific number of times lets say 5
3> Continue the loop.
4> Or a combination of running 5 times but until there are no errors.

I can add the script below to the start menu and it will work fine. However, I would like it to run only if CHKDSK says to run it with /F perhaps using the CHKDSK error codes below and only stop when no more errors are found or run CHKDSK /F when CHDSK says it cant continue due to errors. I can't fine which exit code would be /F and I looked in the event logs but it does not state. I guess I would just say run unless error 0 but I don't know who to integrate the codes with my batch file.

0 Success, no errors found.
1 Success, CHKDSK has detected and fixed major errors.
2 Success, CHKDSK has detected and fixed minor inconsistencies.
3 Error, CHKDSK could not complete.

@echo off
chkdsk.exe c:
echo The drive is okay this time.
goto end

reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v BootExecute /t REG_MULTI_SZ /d "autocheck autochk /p \??\C:\0autocheck autochk *" /f
echo The drive has problems and chkdsk will run next boot

shutdown -r -f -t -10


I am sure this can come in handy to other techs. I just don't have the time to sit looking at the screen.

Eventually I will tie this in with defrag after chkdsk fixes all errors.

Thank you

BC AdBot (Login to Remove)


#2 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer

  • Malware Response Team
  • 12,304 posts
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:10:39 PM

Posted 30 June 2009 - 08:32 AM

If you have to run chkdsk 5 times, then your hard disk is failing and the drive should be replaced. I hope you have backups....

Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#3 Mr LunchBox

Mr LunchBox
  • Topic Starter

  • Members
  • 318 posts
  • Gender:Male
  • Location:California
  • Local time:09:39 PM

Posted 01 July 2009 - 12:51 AM

I thought about the HD being bad but I also have to take into account that these PC's are on literally weeks without being rebooted let alone turned off. I know that since the HD is (aside from the fans) the only components that is always moving they probably are near their expiration.

I rather do CHKDSK then wait weeks for get an HD purchased approved and purchased. The only good thing the company has is the "My Documents" folder re-directed to the server or have a group policy preventing any documents from being saved on the PC.

I can't say they are cheap, actually wait, yes I can't say that they are freaking cheap while make tons of cash

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users