wim32 class?

Discussion in 'Scripting' started by Linn Kubler, Aug 25, 2008.

  1. Linn Kubler

    Linn Kubler Guest


    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

    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 Kubler, Aug 25, 2008
    1. Advertisements

  2. Linn Kubler

    J Ford Guest

    You can use Win32_SystemEnclosure or Win32_Bios
    J Ford, Aug 25, 2008
    1. Advertisements

  3. 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,authenticationLevel=Pkt}!\\" _
    & strComputer & "\root\cimv2")

    Set colItems = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_SystemEnclosure")

    For Each objItem In colItems
    Wscript.Echo "System S/N: " & objItem.SerialNumber

    Set colItems = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_BIOS")

    For Each objItem In colItems
    Wscript.Echo "BIOS S/N: " & objItem.SerialNumber

    Set colItems = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_LogicalDisk WHERE Name='C:'")

    For Each objItem In colItems
    Wscript.Echo "Volume S/N: " & objItem.VolumeSerialNumber
    Also, documentation indicates the properties are read-only, so I believe you
    cannot write values.
    Richard Mueller [MVP], Aug 26, 2008
  4. Linn Kubler

    J Ford Guest

    That's true, greatly depends on the HW Manufactuer
    J Ford, Aug 26, 2008
  5. PowerShell example:

    ยง ATLLAPHROTTENBE {~} Get-WmiObject win32_bios

    SMBIOSBIOSVersion : A08
    Manufacturer : Dell Inc.
    Name : Phoenix ROM BIOS PLUS Version 1.10 A08
    SerialNumber : 7B530C1
    Version : DELL - 27d70403

    If you want to grab just the s/n of a bunch of computers which are in a file:

    $computers = get-content computers.txt
    $results = get-wmiobject win32_bios -computer $computers
    $results | select SerialNumber
    Hal Rottenberg, Aug 26, 2008
  6. Linn Kubler

    Linn Kubler Guest

    First of all, thanks for responding to my question everyone. I delved into
    this and stall am having no luck. The SystemChasis and Bios classes do have
    a serial number field but I'm not sure what serial number it contains,
    doesn't match my system serial number.

    I contacted HP tech support and before they gave me the boot, telling me I
    had to pay for their services, they let slip that the serial number is
    stored in the bios. So I booted up one of my computers here and checked and
    sure enough, it's listed right in the bios under system information.
    Question now is, how do I read the bios information? The wim32_bios class
    doesn't give me anything like this so how do I do it? So far I haven't had
    any luck with google or the scripting center.

    Thanks again,
    Linn Kubler, Aug 26, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.