"Linn Kubler" <> wrote in message
news:...
> Hi,
>
> Is there is a win32 class that returns the serial number of the computer?
> I'm writing some scripts to remotely determine the components of a
> computer in my network and see the win32_computersystem class returns the
> manufacturer and model of the computer but I don't see a property for
> serial number. I know it would be up to the manufacturer to enter the
> data but figured if it at least existed I could populate it myself if
> necessary. I've been looking through the classes but can't seem to locate
> anything so far.
>
> I'm working with Windows XP mostly but suspect I'll be forced to move to
> Vista sometime in the near future.
>
> Thanks in advance,
> Linn
>
Experience may vary, but I find that the SerialNumber property of the
Win32_SystemEnclosure and Win32_BIOS classes is supported in Vista and
Windows Server 2003 and above. On XP and Windows 2000 clients the values are
not populated. However, you can retrieve a VolumeSerialNumber from the
Win32_LogicalDisk class on all clients with WMI installed. For example:
=========
Option Explicit
Dim strComputer, objWMIService, colItems, objItem
strComputer = InputBox("Enter local computer name", "S/N")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,authenticationLev el=Pkt}!\\" _
& strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("SELECT * FROM Win32_SystemEnclosure")
For Each objItem In colItems
Wscript.Echo "System S/N: " & objItem.SerialNumber
Next
Set colItems = objWMIService.ExecQuery _
("SELECT * FROM Win32_BIOS")
For Each objItem In colItems
Wscript.Echo "BIOS S/N: " & objItem.SerialNumber
Next
Set colItems = objWMIService.ExecQuery _
("SELECT * FROM Win32_LogicalDisk WHERE Name='C:'")
For Each objItem In colItems
Wscript.Echo "Volume S/N: " & objItem.VolumeSerialNumber
Next
=========
Also, documentation indicates the properties are read-only, so I believe you
cannot write values.
--
Richard Mueller
MVP Directory Services
Hilltop Lab -
http://www.rlmueller.net
--