Query WMIC in VB.NET / SMART STATUS?

M R
M R used Ask the Experts™
on
Anyone know how to get S.M.A.R.T. drive info from vb.net?

https://code.msdn.microsoft.com/Working-with-Windows-d2509544
https://www.thewindowsclub.com/hard-disk-drive-health

i.e. id like to call a function and have it return if the drive is OK or having issues. Being as smart is enabled and we can query WMIC, id think this is possible. Anyone know how i could modify the above code examples to get that?

Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
start off with this example code https://code.msdn.microsoft.com/Working-with-Windows-d2509544 and customize as required
M R

Author

Commented:
David, Thats the same code i put in my question. I already have that. Im trying to figure out how to query WMI to get S.M.A.R.T. info whether the hard drive is in good health or not and your example doesnt have anything usable.
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
So are you just looking for "function" that you pass a drive letter in to , and it returns the SMART Status of "OK" or "not OK"?

The challenge with these for me typically is working through the associators of the various WMIC classed.  I think the status you are after comes from the DISKDRIVE WMI class, but that doesn't have the drive letter in it.  So you have to figure out a different class that has the drive letter and is somehow associated (sometimes through chained connections) to the DISKDRIVE class.


»bp
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

M R

Author

Commented:
Hello Bill,

 Well actually im just looking for some docs on how to figure out the query to get the smart status. i have code to query WMI for VB i just dont know what Select * from to use if that makes sense.

 And yes youre right normally i would normally need to get a list of drives. in this case its just one drive, the C: so if theres a drive parameter, i'll just hard code in C: or drive 0.
 
 Are there any great articles on available WMI options available / books you would recommend?

Thanks!
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
I'm not going to say these are all "great", some are easier to follow than others, but these are just the WMI related bookmarks I had from my collection.

The last two are tools that can be used when testing out WMI commands and such, in case that's useful.




»bp
M R

Author

Commented:
Thank you Bill, that definitely has some useful WMI info to study. I think im getting closer  i stumbled on this site

https://www.i-programmer.info/projects/38-windows/208-disk-drive-dangers.html?start=2

it seems to have the information needed. Boolean whether the drive is Ok or something else. I.e. does the system have an issue?
I'm going to try and install that project and see if i can weed out the rest of the code and make that into a function.

Select * from Win32_DiskDrive
MSStorageDriver_FailurePredictStatus seems to be the thing to key off of whether the drive has warnings or not.

Thanks
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
Interesting, I'll be interested to see how you make out.

I'm pretty sure you will have to run in elevated privs to access MSStorageDriver_FailurePredictStatus in \root\wmi so be aware of that.


»bp

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial