0

I need to build in a call in my app to check SSD health status. I've tried multiple examples from different sources but cannot get anything to work. In all examples I've tried I get the "Not supported" exception in ManagementObjectSearcherquery or foreach (ManagementObject data in searcher.Get()) loop

All the examples I've found are pretty outdated so did anything change? I'm running Windows 10 with .NET 4.6.2. You'd think there would be a "modern" call to access SMART data. Any help would be greatly appreciated! Thank you!

SYB
  • 153
  • 2
  • 11
  • Can you provide a code sample? Like a single method that is supposed to do this? – UnhandledExcepSean Feb 20 '19 at 21:49
  • You may take a look at this answer. https://stackoverflow.com/a/14894138/2793683 – dmoore1181 Feb 20 '19 at 21:50
  • Here's one example that crashes right away http://vasters.com/archive/Reading-ATAPI-SMART-Data-From-Drives-Using-NET-Temperature-Anyone.html – SYB Feb 20 '19 at 21:55
  • @ dmoore1181 yes, I tried that one and it crashes in this loop with "Not supported": `// check if SMART reports the drive is failing ... foreach (ManagementObject drive in searcher.Get()) { dicDrives[iDriveIndex].IsOK = (bool)drive.Properties["PredictFailure"].Value == false; iDriveIndex++; }` – SYB Feb 20 '19 at 22:02
  • By the way, the example that dmoore1181 provided is supposedly designed similar to Crystal Disk tool and yet this tool works flawlessly on my computer. – SYB Feb 20 '19 at 22:05

1 Answers1

0

Turns out something was blocking this code on my dev computer. Even powerShell script returned the same error. I ran it on the production machines and it works as expected. Didn't get to the bottom of this on my dev PC but this is secondary.

SYB
  • 153
  • 2
  • 11