# [SOLVED] [C#] WMI Mainboard modelname



## Emphyrio (May 16, 2009)

I've got troubles finding the Mainboard Model name thru WMI.

I use the following code :



> ManagementObjectSearcher objMOS = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_BaseBoard");
> foreach (ManagementObject Mobject in objMOS.Get())
> {
> lblMan.Text = "Mainboard : " + (Mobject["Manufacturer"]);
> }


This gives me the manufacture (MSI)
But I need the Model of this board (MS-7528)

I wend thru the properties of *Win32_BaseBoard* but can't find any good value 

Is there a solution I can use ?

Thanks in advance


----------



## Wrench97 (May 10, 2008)

*Re: [C#] WMI Mainboard modelname*

Coding I can't help with but I can tell you if it is not a retail board a lot of the time the info on model number is not there. OEM's either use their own name for the model(HP) or none at all like Dell.

Another thing to watch is the MSI MS-xxxx numbers they can be multiple model name boards, some MS-xxxx models I've seen have different names, different sockets(939. AM2) at times I think it's more of a PCB number then a model number.


----------



## Emphyrio (May 16, 2009)

*Re: [C#] WMI Mainboard modelname*

Hi Wrench97,

Thanks for replying.

You could have a point there, because when I use (Mobject["SerialNumber"] I get : "To Be Filled In By OEM".

Weird thing is that *msinfo32.exe* gets it right 

What you mean by PCB number?


----------



## Wrench97 (May 10, 2008)

*Re: [C#] WMI Mainboard modelname*

PCB = Printed Circuit Board, MSI could use the same board adding or subtracting components to make entirely different model boards. I.E. 1, 2, or 3 PCIe x16 slots, DDR2 ram slots or DDR3 slots, AM2 socket or AM3 socket. 

See if CPUz gets it right(Mainboard tab) > CPUz


----------



## Emphyrio (May 16, 2009)

*Re: [C#] WMI Mainboard modelname*

Thanks again, Wrench97 

CPU-Z gives me:











I narrowed my problem down too *Win32_ComputerSystem*

This vbs script should work:



> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> 
> Set CS_Info = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
> ...


But I can't seem to implement (convert it) into use for C#



> ManagementObjectSearcher objMOS = new ManagementObjectSearcher("\\root\\cimv2","SELECT * FROM Win32_ComputerSystem ");
> foreach (ManagementObject Mobject in objMOS.Get())
> {
> lblMan.Text = "Mainboard : " + (Mobject["Manufacturer"]) + Environment.NewLine + "Model : " + (Mobject["Model"]) + Environment.NewLine;
> }


Gives me a error : System.Management.ManagementException was unhandled


----------



## Wrench97 (May 10, 2008)

*Re: [C#] WMI Mainboard modelname*

Oh I think I see what your trying to do, get the make/model remotely through a #c programing query?

John(jcgriff) would be a good source though I believe he's using vb scripts.


----------



## Emphyrio (May 16, 2009)

*Re: [C#] WMI Mainboard modelname*



wrench97 said:


> Oh I think I see what your trying to do, get the make/model remotely through a #c programing query?


Indeed  thru WMI.


----------



## Wrench97 (May 10, 2008)

*Re: [C#] WMI Mainboard modelname*

Sometimes you just have to tap me in the head with a 2x4 and I'll get it:laugh:


----------



## Emphyrio (May 16, 2009)

*Re: [C#] WMI Mainboard modelname*



wrench97 said:


> Sometimes you just have to tap me in the head with a 2x4 and I'll get it:laugh:


Well I think some else get me tapped with that same gear and show me the solution. :laugh: 

I am surten that I overlooked something obiviousely :laugh: 

Thanks so much for your reply's, Wrench97 :wave:


----------



## Emphyrio (May 16, 2009)

*Re: [C#] WMI Mainboard modelname*

I've got it !  

I told you I was overlooking something, namely a space :embarased
Debugging can be a pain 

The solution is :



> ManagementObjectSearcher objMOS = new ManagementObjectSearcher("\\root\\cimv2","SELECT * FROM Win32_ComputerSystem");
> foreach (ManagementObject Mobject in objMOS.Get())
> {
> lblMan.Text = "Mainboard : " + (Mobject["Manufacturer"]) + Environment.NewLine + "Model : " + (Mobject["Model"]) + Environment.NewLine;
> }


Notice the difference


----------



## jcgriff2 (Sep 30, 2007)

Very nice app - incredible detailed info + GUI. Wow!

I use batch & VBS to obtain numerous files from OPs (No GUIs... yet; not very familiar with C# yet).

My simple WMI VBS script to display comp manufacturer & model -

```
strComputer = "." 

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
Set xComputer = objWMIService.ExecQuery("Select * from Win32_ComputerSystem") 

For Each objComputer in xComputer 
Wscript.Echo "Manufacturer: " & objComputer.Manufacturer _
& vbCr & "Model: " & objComputer.Model
Next 

WScript.Quit
```
Glad you found the space.

Regards. . .

John

`


----------



## Emphyrio (May 16, 2009)

Thanks, John, you made me blush   :redface:

WMI scripting isn't my cup of tea, but I find it usefull in finding the "hidden" goodies and implement them in C#.

The pic is for the next update for the tool whitch includes a "Updater".


Kind greetings,

Emphyrio


----------



## Wrench97 (May 10, 2008)

Nice app. glad you got it sorted out


----------



## Emphyrio (May 16, 2009)

Thank you, Wrench97 :wave:


----------

