Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Hard drive serial (manufacturer) number

  • 17-05-2007 03:00PM
    #1
    Registered Users, Registered Users 2 Posts: 1,821 ✭✭✭


    Just wondering if it is possible to retrieve hard drive manufacturer serial number... I used this example here:

    http://www.codeproject.com/csharp/hard_disk_serialno.asp

    where it accesses the wmi. Problem is, it doesn't work all the time. I've noticed if a computer is running .net framework 2.0 (i used 1.1) then it doesn't work. I don't have the ability to test it on 3.0

    the problem is when trying to access the SerialNumber variable in the Win32_PhysicalMedia API.
     // get the hardware serial no.
        if (wmi_HD["SerialNumber"] == null)
         hd.SerialNo = "None";
        else
         hd.SerialNo = wmi_HD["SerialNumber"].ToString();
        
        ++i;
    

    Can anybody point me in the right direction? It just displays None, when I try run it on .net 2.0


Comments

  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    you could try this VBScript here, see what results you get.

    [PHP] strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
    Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_PhysicalMedia")
    For Each objPhysicalMedia in colSettings
    Wscript.Echo "Serial Number: " & _
    objPhysicalMedia.SerialNumber
    Next[/PHP]

    might be your operating system doesn't support it? i know highly unlikely..but just incase.
    could be just doesn't have one!


  • Registered Users, Registered Users 2 Posts: 1,821 ✭✭✭Skud


    that didn't work. I have an idea what might be going wrong with it though... Comes with a default hard drive password. Maybe that's why windows wasn't picking it up, being built with that.

    BTW for future information, Windows Genuine Advantage records the serial of the hard drive. If that doesn't, then it's not recognised in windows :p


Advertisement