File: D:/bin/diskcheck/diskcheck.cmd
rem SS, 24/9/09 to check hard disk status and email if problem found by checking for "errors" or "at risk"
d:
cd d:\bin\diskcheck
rem run the commands in script.txt, output result to op.txt, if command failed then report error
date /t >op.txt
time /t >>op.txt
diskpart /s script.txt >>op.txt
if ERRORLEVEL 1 goto diskparterror
rem if errorlevel 1 or greater
rem check for "errors" or "at risk" in op.txt, if found then report error
:continue1
find /i "errors" op.txt
if ERRORLEVEL 1 goto continue2
goto diskproblem
:continue2
find /i "at risk" op.txt
if ERRORLEVEL 1 goto continue3
goto diskproblem
:continue3
echo Hard disk okay >>op.txt
itpSendEmail low surinder@itpartnership.com diskcheck@itpartnership.com "Disk Check Results" op.txt
goto end
:diskparterror
echo. >>op.txt
echo diskpart returned errorlevel %ERRORLEVEL% >>op.txt
goto sendemail
:diskproblem
echo. >>op.txt
echo Hard disk problem found >>op.txt
goto sendemail
:sendemail
itpSendEmail high purchases@itpartnership.com diskcheck@itpartnership.com "ITP ALERT!!! Possible 1and1 Server Hard Disk Problem" op.txt
:end
rem add to log
echo. >>log.txt
type op.txt >>log.txt
echo ------------------------------------------------------------------------------->>log.txt