Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

VBScript to return the actual serial number of a hard drive

Status
Not open for further replies.

galli

IS-IT--Management
Apr 16, 2004
21
NZ
Hi there

Does anyone know how to use vbscript to retreive the correct serial number of a HDD using WMI. The Script I am using uses Win32_PhyicalMedia and returns a string that is I beleive encrypted. Here is my Code:

Code:
strComputer = "."

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
str = ""

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PhysicalMedia")
   For Each objItem In colItems
      str = str & "SerialNumber: " & objItem.SerialNumber & vbCrlf & vbCrlf
   next
msgbox str

The make of Hard drive I am attempting to get the serial number from is a western digital. Any Help is greatly appreciated ;-)
 
You may try this:
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
str = ""
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk")
For Each objItem In colItems
   str = str & objItem.Name & " SerialNumber: " & objItem.VolumeSerialNumber & vbCrlf & vbCrlf
Next
MsgBox str

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I thought that also but this only returns the volume serial number this is not the actual serial number.
I have been lead to beleive that the only way to get the HDD serial number is to use win32_PhysicalMedia it works with some brands of hard drives but not western digital.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top