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.
if ERRORLEVEL 2 goto ADD_CHECK
echo The drive is okay this time.
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.