I am attempting to put together a batch file that will run a chkdsk on all local drives on servers in our environment. Once the chkdsk is complete, it should create a log entry in the System log via the eventcreate utility. When I attempt to run the script below, it correctly runs the chkdsks but reports back on every drive letter, even if it wasn't checked.
I am not very experienced with this, so any help would be great. Thanks!
for %%x in (C D E Q S T U) do (
if exist %%x:\ chkdsk %%x: /i
if ERRORLEVEL 0 goto ERRORLEVEL 0
if ERRORLEVEL 1 goto ERRORLEVEL 1
if ERRORLEVEL 2 goto ERRORLEVEL 2
if ERRORLEVEL 3 goto ERRORLEVEL 3
eventcreate /l SYSTEM /so chkdsktest /t INFORMATION /id 10 /d "No errors were found on %%x."
eventcreate /l SYSTEM /so chkdsktest /t INFORMATION /id 11 /d "Errors were found and fixed on %%x."
eventcreate /l SYSTEM /so chkdsktest /t WARNING /id 12 /d "Performed disk cleanup (such as garbage collection) or did not perform cleanup because /f was not specified on %%x."
eventcreate /l SYSTEM /so chkdsktest /t ERROR /id 13 /d "Could not check the disk, errors could not be fixed, or errors were not fixed because /f was not specified on %%x."