How do I obtain the computer manufacturer’s name?
One customer wanted a way to determine the name of thecomputer manufacturer.For example, they wanted to make some function call andget back “IBM” or “Compaq” or “Dell”.I don’t know why they wanted this information,and for the moment, I don’t care.
And of course, when you’re looking for information,you don’t search MSDN; that’s for crazy people.No, let’s just fire up regedit and hit Ctrl+F.(I can’t imagine how many application compatibility bugswere created by that “helpful” Ctrl+F dialog in regedit.)
The customer found the registry keys that are usedto customize the System control panel,as well asthe OEMINFO.INI file that also takes part.But then the question of reliability arose.After all, since it’s just a registry key and an INI file,the user could just edit it and make it say anything they want.If the customer wiped their hard drive and reinstalled Windowsfrom scratch, then this information would be lost, too.This customer wanted some degree of assurance that ifthe computer claimed to be a Dell, then it really was a Dell.
Enter WMI.The Scripting Guys are all over WMI.If you search for the phrase “from Win32_ComputerSystem”you will find hit after hit from the Hey, Scripting Guy!column.
And it so happens that WMI exposes the computer manufacturer infoas well.If you look at the scripts that the Scripting Guys put out,probably two thirds of them fall into this pattern:
strComputer = “.” Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”) Set colItems = objWMIService.ExecQuery(“Select * from something“) For Each objItem in colItems Wscript.Echo objItem.something Next
All we have to do is fill in the “something”.
strComputer = “.” Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”) Set colItems = objWMIService.ExecQuery(“Select * from Win32_ComputerSystem“) For Each objItem in colItems Wscript.Echo “System Name: ” & objItem.Name Wscript.Echo “Manufacturer: ” & objItem.Manufacturer Wscript.Echo “Model: ” & objItem.Model Wscript.Echo Next
Okay, so great, we can use WMI to get this information.But how reliable is it?
Well, the WMI folks tell me that they get the information byquerying theSMBIOSdirectly, so it’s as reliable as your BIOS.Major manufacturers will put their names into the BIOS¹,but if you’re running on a home-built machine, the valuesare whatever came with your motherboard.The BIOS manufacturers typically put placeholder strings intotheir SMBIOS, setting the manufacturer to a generic string like“Manufacturer”, for example.When the motherboard manufacturer installs the BIOS,they’re supposed to replace the placeholder strings withsomething more meaningful, but most of them don’t bother.The result is that a machine you put together from partsyou bought at the local computer shop will most likelyjust say “Manufacturer” for the manufacturer.
In summary, if you query WMI for the computer manufacturerand it comes back “Dell”, then you can be pretty sure you have a Dell.(Either that or somebody with way too much time on their handsburned a custom BIOS that says “Dell”.)On the other hand, if it comes back as “Manufacturer” then you’restill in the dark.All you know is you’ve got some sort of generic computer.
¹Even though major manufacturers will put their nameinto the BIOS,I’m told that if you send your computer back to the manufacturerand they replace the motherboard,they will sometimes forget to burn their name into the BIOS ofthe replacement motherboard.As a result, even on a name-brand computer,you might see “Manufacturer”.
0 comments