KB-44853: Returning the HD’s serial number.

Question:

How can I return the serial number of an HD installed in the computer?

Solution:

It is possible to do so by using the script below. It lists all serial numbers of the HDs and disk units in the computer. In this example, the script is fired in any of the application’s buttons’ Click() event:

Sub CommandButton1_Click()
‘Script to display HDs’ serial numbers
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)
Set colItems = objWMIService.ExecQuery(“SELECT * FROM Win32_PhysicalMedia”)
For Each objItem In colItems
       str = “SerialNumber: “ & objItem.SerialNumber
       ‘Using a message box to to display the HDs’ serial number
       MsgBox str
Next
End Sub

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Deixe seu Comentário

Seu endereço de e-mail não será publicado. Campos marcados com asterisco são obrigatórios *