[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 707
  • Last Modified:

Get hardware information

Hello

Another question from a VB.Net newbie.
I have a small task where I have to retrieve a limited set of information about computer hardware. The details I need are the make, model and serial number (if possible) for the following devices:

1. Network Adapter
2. Graphics chip or card
3. Sound chip or card
4. Motherboard
5. HDD
6. Default printer

I've been able to find out how to get details for some stuff such as BIOS (except the manufacturer), printer settings and so on but not the make, model or serial number.

I have spent several days searching EE and the net for answers before deciding to pose the question

I'm sure that the solution will be fairly simple but since my need is urgent, I have allocated 500 points. I would have made it 1000 but the field wouldn't let me.
0
jindalee
Asked:
jindalee
  • 5
  • 3
2 Solutions
 
SStoryCommented:
I think you'd have to use WMI.
Does this help?

http://www.freevbcode.com/ShowCode.asp?ID=4571
0
 
jindaleeAuthor Commented:
Thanks. It helps a little but gives me no idea how I get info about NICs, graphics etc
0
 
SStoryCommented:
Well, the registry key shown here
http://www.java2s.com/Tutorial/CSharp/0520__Windows/GetNetworkCardInformationfromRegistry.htm

shows you how to get the name of the mfg of the card. I don't know about the serial number.

0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
SStoryCommented:
This will give you more information about NIC cards from within vb.net:

'this gives the info on the first NIC card
System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(0)

of course you'd need to do .whatever after the (0) to get to the properties list
0
 
jindaleeAuthor Commented:
Thanks sstory. I am now 1/6th the way to getting the details I need. It was in C# so I had to convert to VB. The code is attached for anyone else who needs the same info.
        Dim keyName As String = ""
        Dim cardServiceName As RegistryKey
        Dim networkcardKey As String = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards"
        Dim serviceKey As String = "SYSTEM\\CurrentControlSet\\Services\\"
        Dim networkcardKeyName As String = "", deviceName As String = "", deviceServiceName As String = "", serviceName As String = ""
        Dim serviceNames As RegistryKey
        serviceNames = Registry.LocalMachine.OpenSubKey(networkcardKey)
        If serviceNames.ToString() = "" Then
            Console.WriteLine("Bad registry key")
        End If
        Dim networkCards As String() = serviceNames.GetSubKeyNames()
        serviceNames.Close()
 
        For Each keyName In networkCards
            networkcardKeyName = networkcardKey + "\\" + keyName
            cardServiceName = Registry.LocalMachine.OpenSubKey(networkcardKeyName)
            If cardServiceName.ToString() = "" Then
                Console.WriteLine("Bad registry key: {0}", networkcardKeyName)
            Else
                deviceServiceName = cardServiceName.GetValue("ServiceName").ToString()
                dg.Rows.Add()
                dg.Rows(iRows).Cells(0).Value = "Network Connection"
                dg.Rows(iRows).Cells(1).Value = ""
                iRows = iRows + 1
                deviceName = cardServiceName.GetValue("Description").ToString()
                dg.Rows.Add()
                dg.Rows(iRows).Cells(0).Value = "Network Adapter Name"
                dg.Rows(iRows).Cells(1).Value = deviceName.ToString()
                iRows = iRows + 1
            End If
        Next
        serviceNames.Close()

Open in new window

0
 
SStoryCommented:
Yes...but I don't imagine you can get the serial number that way..

I have NO experience with WMI, but suspect it might be the answer.  Here is something I found on it:
http://www.thescarms.com/dotnet/WMI.aspx
0
 
grayeCommented:
Yes, you can get everything on your list using WMI... including the serial number of the PC.
Take a look at the following for a short tutorial on programming WMI. http://www.emmet-gray.com/Articles/WMI_Intro.htm
I've also got a complete application that you can download to perform this function.... it might be complete overkill (since it records a gazillion thing other than the few you've mentioned).   But you're welcome to take a look (and download the complete VB.Net source code)  http://www.sosos.emmet-gray.com/
0
 
SStoryCommented:
graye, looks really cool.
0
 
jindaleeAuthor Commented:
Thanks.  Completely meets my needs.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now