Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the Hard Drive Serial Number given by the Manufacturer with

Status
Not open for further replies.

nitin36537

Civil/Environmental
Feb 16, 2001
60
IN
How to get the Hard Drive Serial Number given by the Manufacturer with VBA?

Please note that I need Number given by Manufacturer & not Hard drive serial number which is a random number that is generated by DOS or Windows every time you format your hard drive.

Thanks


 
Replies continue below

Recommended for you

You might check at Tek-Tips.com - a sister site to this one and it is where the computer geeks live.
 
Check with the hard drive manufacturer. Most of them have tools for that.
 
There is some code buried in the discussion here:

I have re-written it to work as an Excel UDF:

Code:
Function GetPhysicalSerial() As Variant

Dim obj As Object
Dim WMI As Object
Dim SNList() As String, i As Long, Count As Long

Set WMI = GetObject("WinMgmts:")

For Each obj In WMI.InstancesOf("Win32_PhysicalMedia")
If obj.SerialNumber <> "" Then Count = Count + 1
Next

ReDim SNList(1 To Count, 1 To 1)

i = 1
For Each obj In WMI.InstancesOf("Win32_PhysicalMedia")
 SNList(i, 1) = obj.SerialNumber
i = i + 1
If i > Count Then Exit For
Next

GetPhysicalSerial = SNList
End Function

Paste into a VB code module, then enter =GetPhysicalSerial() anywhere on a worksheet. If you have more than one physical hard drive enter as an array function to return the serial number for each drive.

Doug Jenkins
Interactive Design Services
 
What other information we can get from WinMgmts: ?
 
What other information we can get from WinMgmts: ?

I can't help there at the moment. I have never seen this object before, and I don't recall reading about it in any book I have. I can only suggest following up the links in the discussion I linked to in my previous post. If I have time to do some research myself I will post something on my blog, but I don't know when that will be.

Doug Jenkins
Interactive Design Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top