Get hardware manufacturer and system model number in VB.net?

rabbitt picture rabbitt · Apr 1, 2014 · Viewed 11k times · Source

I'm trying to get the hardware manufacturer (e.g. "Dell") and the model number (e.g. "Latitude E6320") using vb.net but I'm having no luck.

I've tried

Dim opSearch As New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")
Dim opInfo As ManagementObject
For Each opInfo In opSearch.Get()
    Return opInfo("manufacturer").ToString()
Next

Though this returns "Microsoft Corporation" not "Dell".

Answer

Ňɏssa Pøngjǣrdenlarp picture Ňɏssa Pøngjǣrdenlarp · Apr 2, 2014

You are polling the wrong WMI class/hive. Of course Microsoft is the OS manufacturer; what you need is Win32_ComputerSystem:

Imports System.Management


cs = New ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem")

For Each objMgmt In cs.Get
   _Manufacturer = objMgmt("manufacturer").ToString()
   _Model = objMgmt("model").ToString()
   _SystemType = objMgmt("systemtype").ToString
   _totalMem = objMgmt("totalphysicalmemory").ToString()
Next

Manufacturer will be something like "Dell, Inc", Model comes out spot on with mine, but has been known to sometimes include internal sub model identifiers. System type comes back as "x64-based PC" on mine.

MS has a WMI query builder somewhere to help fnd and use the right query, though it generates very wordy code.