bharath
bharath

Reputation: 14453

How to count the motherboard slots and get the motherboard serial number through java?

How to count the motherboard slots and get the motherboard serial number through java? Im using Sigar Java API for getting all other informations. But i don't know how to get the mentioned informations.

Upvotes: 1

Views: 891

Answers (1)

Sandeep Kumar
Sandeep Kumar

Reputation: 692

I think Sigar does not provide such information yet. But we can gather information in another way. I don't know about how to get MotherBoard slots but MotherBoard serial number can be get very easily using VBS (Window Script).

Just write down the below script in a file with extension .vbs

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery _ 
("Select * from Win32_BaseBoard") 
For Each objItem in colItems 
    Wscript.Echo objItem.SerialNumber 
    exit for  ' do the first cpu only!

Invoke these file using Runtime class as,

Process p = Runtime.getRuntime().exec("cscript //NoLogo " + "my.vbs");
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
      String line;
String result = "";
  while ((line = input.readLine()) != null) {
     result += line;
  }
  input.close();
System.out.println(result);

Note: This way will work only on Window machines because it's platform depended code for Windows OS only.

Upvotes: 0

Related Questions