automating chkdsk & dfrg - TechRepublic
General discussion
August 30, 2004 at 09:21 PM
dpchris

automating chkdsk & dfrg

by dpchris . Updated 20 years, 7 months ago

I implemented a script I downloaded from techrepublic called chkfrag_defrag.zip. Anyways, the document talks about being able to automate the script with XP’s Task Scheduler.

I found that if I don’t run the command script from the dos shell, it doesn’t appear to run at all. Is there a work around this? The script is as follows:

REM chkdsk and defrag automation
for /F “eol= tokens=1 delims=( ” %%i in (DrvLtr.txt) do set DrvLtr=%%i& call :dsKchk

:dsKchk
If %DrvLtr% == end goto :eof
chkdsk %DrvLtr%
If not errorlevel 3 goto :defrag
If not exist %DrvLtr%\winnt If not exist %DrvLtr%\windows If not exist %DrvLtr%\pagefile.sys goto :dskchkon

:dskchkoff
cd\
%DrvLtr%
echo Y chkdsk /F /R
goto :defrag

:dskchkon
chkdsk %DrvLtr% /F /R

:defrag
cd\
%DrvLtr%
defrag %DrvLtr% -b
defrag %DrvLtr%
:EOF

This discussion is locked

All Comments