java如何获取本机主板序列号?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java如何获取本机主板序列号?相关的知识,希望对你有一定的参考价值。
java如何获取本机主板序列号?
public static String getMotherboardSN()String result = "";
try
File file = File.createTempFile("realhowto", ".vbs");
file.deleteOnExit();
FileWriter fw = new java.io.FileWriter(file);
String vbs = "Set objWMIService = GetObject(\"winmgmts:\\\\.\\root\\cimv2\")\n"
+ "Set colItems = objWMIService.ExecQuery _ \n"
+ " (\"Select * from Win32_BaseBoard\") \n"
+ "For Each objItem in colItems \n"
+ " Wscript.Echo objItem.SerialNumber \n"
+ " exit for ' do the first cpu only! \n" + "Next \n";
fw.write(vbs);
fw.close();
Process p = Runtime.getRuntime().exec(
"cscript //NoLogo " + file.getPath());
BufferedReader input = new BufferedReader(new InputStreamReader(
p.getInputStream()));
String line;
while ((line = input.readLine()) != null)
result += line;
input.close();
catch (Exception e)
e.printStackTrace();
System.out.println(result);
return result.trim();
public static void main(String[] args)
getMotherboardSN();
这个是我在网上找的,但是只能在windows下获得主板序列号,在linux下就不行。我愁~在linux下如何获得主板序列号呢。 参考技术A baqfa
631 参考技术B jky
680 参考技术C nymp
802
以上是关于java如何获取本机主板序列号?的主要内容,如果未能解决你的问题,请参考以下文章