Get drive health or wearout percentage?

Peter Volz 1,295 Reputation points
2023-10-14T15:29:21.25+00:00

Hello experts,

Is there any way in vb.net (or C#) to get the system drive health?

My Samsung Magician shows drive health as Good: 94.2 TB written.

Can we get this data using .net? Mostly for m2 or sata drives.

What about getting the S.M.A.R.T status?

Thanks :)

Developer technologies | VB
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 90,686 Reputation points
    2023-10-14T18:33:50.4066667+00:00

    You can use WMI with MSFT_Disk (HealthStatus)

    or

    VDS interfaces with VDS_DISK_PROP (VDS_HEALTH)

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Peter Volz 1,295 Reputation points
    2023-10-15T19:25:31.9433333+00:00

    Thanks for the tip, I've found this:

    Dim MyMClass As ManagementClass = New ManagementClass(".\ROOT\Microsoft\Windows\Storage:MSFT_Disk")
    For Each MyMObject As ManagementObject In MyMClass.GetInstances()
        MyMObject("HealthStatus").ToString > 0=OK 1=Warning 2=Error Else=UnknownNext
    Next
    

    Is this correct? Because I just need this data for the system / boot drive, nowhere specified that in the code.

    Best :)


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.