TechnicallyChris.com

Technical and Personal Ramblings of a Bostonian
  • Home
  • About Chris
  • Donate
  • Contact Chris
Home > Random Code > Capturing S.M.A.R.T. Hard Disk Data from WMI with AutoIt

Capturing S.M.A.R.T. Hard Disk Data from WMI with AutoIt

September 11th, 2009
Goto comments Leave a comment

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

If you enjoyed this article or it helped you in any way, I’d appreciate it if you’d post a comment below to let me know. All code examples are for demonstration only and should be used at your own risk. I cannot accept liability for unexpected results.

Chris Random Code Scripts

Comments (5) Trackbacks (0) Leave a comment Trackback
  1. Mike Dixon
    February 23rd, 2010 at 15:12 | #1
    Reply | Quote

    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.

  2. Mike Dixon
    February 24th, 2010 at 17:13 | #2
    Reply | Quote

    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.

  3. Chris
    March 2nd, 2010 at 00:48 | #3
    Reply | Quote

    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.

  4. Bruce
    May 29th, 2010 at 03:30 | #4
    Reply | Quote

    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.

    • Chris
      May 29th, 2010 at 07:31 | #5
      Reply | Quote

      Hi Bruce, SMART only looks at internal fixed disks, so it’s not going to see that attached drive.

  1. No trackbacks yet.
Subscribe to comments feed
What’s Happened to Customer Service (Part 1)? Adjusting DCOM Settings via Script
RSS feed
  • Google
  • Youdao
  • Xian Guo
  • Zhua Xia
  • My Yahoo!
  • newsgator
  • Bloglines
  • iNezha

Sponsored By

RoboForm: Learn more...Read my review of RoboForm here.

Recent Posts

  • Just Bought the Google Nexus One
  • Seven Things I’ve Liked About Windows 7 in Seven Day
  • What’s Happened to Customer Service (Part 2)?
  • What’s Happened to Customer Service (Part 1)?
  • Capturing S.M.A.R.T. Hard Disk Data from WMI with AutoIt
  • Adjusting DCOM Settings via Script
  • How to Manually Call the Google Cache
  • RoboForm & RoboForm2Go Product Review
  • Updated PingCell Function for Excel
  • Creating Hyperlinks in Word and Excel Longer than 256 Characters

Categories

  • ColdFusion
  • Firefox
  • Google Nexus One
  • IIS
  • McAfee EE / SafeBoot
  • Microsoft Windows
  • Oracle
  • Random Code
  • Random Technology
  • Sports and Recreation
  • Subversion
  • The Untechnological

Archives

  • January 2010
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • October 2007
  • September 2007
  • August 2007
  • January 2007
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006

Meta

  • Register
  • Log in
PageRank
Top WordPress
Copyright © 2006-2010 TechnicallyChris.com
Theme by mg12. Valid XHTML 1.1 and CSS 3.