Make chkdsk /f run a certain number of times

  • Thread starter Thread starter Rich
  • Start date Start date
R

Rich

I've inherited a bunch of computers that probably haven't had any good
maintenance done on them in years. On all the ones I've sat down at so far,
i've had to run chkdsk /f then reboot multiple times till chkdsk says the
disk is fine again.

Is there any way to automate this with a batch file, to initiate a chkdsk c:
/f, then restart the workstation, then do the same process again, up to a
certain amount of times i specify somewhere?

While doing it say 10 times on every computer may be overkill, if i could do
this systematically by just scheduling a task on all the computers, rather
than doing the whole process at each one, that would save me a TON of time.
Thanks!!
 
You COULD do that OR you could paste in the following which will cause
checkdisk to run automatically on next boot only IF the drive needs it -
i.e. if by running chkdsk, it reports that it has found errors and needs to
be run again with the /f option.


------------------------copy between lines------------------------

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

reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v
BootExecute /t REG_MULTI_SZ /d "autocheck autochk /p \??\C:\0autocheck
autochk *" /f

echo.
echo The drive has problems and chkdsk will run next boot

:end

------------------------copy between lines------------------------


*NB - Please note that the line that begins reg ADD ends with /f
but may appear as two or three lines due to line-wrap. Make sure all of
this between 'reg ADD' and '/f' is all on one line.

Then run this file at startup either by placing it in your startup folder or
better - by copying it into a startup or logon script using the Group Policy
Editor.
 
that sounds even better! thanks!!

Tim Meddick said:
You COULD do that OR you could paste in the following which will cause
checkdisk to run automatically on next boot only IF the drive needs it -
i.e. if by running chkdsk, it reports that it has found errors and needs to
be run again with the /f option.


------------------------copy between lines------------------------

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

reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v
BootExecute /t REG_MULTI_SZ /d "autocheck autochk /p \??\C:\0autocheck
autochk *" /f

echo.
echo The drive has problems and chkdsk will run next boot

:end

------------------------copy between lines------------------------


*NB - Please note that the line that begins reg ADD ends with /f
but may appear as two or three lines due to line-wrap. Make sure all of
this between 'reg ADD' and '/f' is all on one line.

Then run this file at startup either by placing it in your startup folder or
better - by copying it into a startup or logon script using the Group Policy
Editor.
 
Hi Rich,
Let me know how it works for you or if you have any probs.
If necessary, you can always email me directly as I was truthful when it
came to filling in my OE settings.
(in OE choose 'reply to sender' instead of group)
 
Back
Top