Capturing S.M.A.R.T. Hard Disk Data from WMI with AutoIt
September 11th, 2009
For those who are unaware, there is a monitoring and reporting systems for modern hard disks known as SMART. I’ll save the explanations for Wikipedia’s S.M.A.R.T. page. Instead of my normal big script example, I’d like to provide you with a snippet that basically just loops over the known data from WMI using AutoIt. You can modify this however you’d like to return error codes if failures are found, write out to logs, etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ; Check WMI for FailurePredictStatus $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $objWMIService = ObjGet("winmgmts:\\.\root\WMI") $smart = $objWMIService.ExecQuery("SELECT * FROM MSStorageDriver_FailurePredictStatus", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($smart) then For $item In $smart ConsoleWrite("Instance Name: " & $item.InstanceName) ConsoleWrite("Active: " & $item.Active) ConsoleWrite("Predict Failure: " & $item.PredictFailure) ConsoleWrite("Reason: " & $item.Reason) ConsoleWrite(@CRLF) Next EndIf |

I just found this site searching for a way to read SMART data and forward it to another program.
This code not only does what I want, it also introduced me to AutoIt. It’s been years since I wrote any scripts whatsoever and now I have a whole new interest in it.
Thanks, Chris, for inspiring me again.
Chris, just a simple question.
I only have one HDD in my computer but I do have an external USB HDD. Will this script show just the internal drives or can it be made to show the USB as well. I’m asking because I do not see my USB drive using this script but Win7’s Disk Management shows it as healthy.
Hi Mike, glad you found AutoIt! I happened upon it a few years ago and it certainly has its uses. Regarding external drives, I don’t think these are monitored by the BIOS so they wouldn’t show up in any SMART reports.
I’m not 100% on this because I can’t find any reference to it either way – but I don’t see any of mine when I query WMI directly so it’s an educated guess.
Chris, just a simple question.
I only have one HDD in my computer but I do have an external USB HDD. Will this script show just the internal drives or can it be made to show the USB as well. I’m asking because I do not see my USB drive using this script but Win7’s Disk Management shows it as healthy.
Hi Bruce, SMART only looks at internal fixed disks, so it’s not going to see that attached drive.