是否存在一种可以在java中使用WMI类的方法 [英] Does there exist a way by which i can use WMI classes in java
问题描述
您好我想使用WMI类来查找应用程序和产品信息。但问题是我想使用java或任何脚本语言,如python,javascript或perl。我听说过JWMI,它可能是一个选择。任何人都可以帮我这个???
Hi i want to use WMI classes to find out the application and products information. But the problem is that i want to use java or any scripting language like python, javascript or perl. I have heard about JWMI, it may be an option. Can anyone help me regarding this???
推荐答案
JavaScript和Java不是一回事。
JavaScript and Java aren't the same thing.
JavaScript可在Windows Scripting Host(WSH)下使用。有了它,访问WMI相当容易:
JavaScript is available under Windows Scripting Host (WSH). With it, it is fairly easy to access WMI:
var loc = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = loc.ConnectServer(".", "root\\cimv2");
coll = svc.ExecQuery("select * from Win32_Process");
var items = new Enumerator(coll);
while ( !items.atEnd() )
{
WScript.Echo(items.item().Name);
items.moveNext();
}
jWMI(Java)
jWMI是一个小型库,可以让Java进行一般的WMI查询。它似乎是在这里可用
http:// henryranch .net / software / jwmi-query-windows-wmi-from-java /
它似乎也很容易使用(虽然我不确定它有多强大或完成它是):
It also seems easy to use (though I am not sure how powerful or complete it is):
String name = getWMIValue("Select Name from Win32_ComputerSystem", "Name");
WBEM(Java)
WMI是Microsoft的 基于Web的企业管理 (WBEM)的实现。还有一个一般WBEM的Java实现,它将在某种程度上与WMI兼容。
WBEM (Java)
WMI is a Microsoft implementation of Web Based Enterprise Management (WBEM). There is also a Java implementation of general WBEM which will be at some level compatible with WMI.
这可能是您将要找到的最完整的真正Java实现。如果您的需求高于微小脚本(例如实现WBEM / WMI提供程序),那么您可能需要查看此选项。
This might be the most complete true Java implementation you're going to find. If your needs are above tiny scripting (such as implementing a WBEM/WMI provider), then you might want to look into this option.
这篇关于是否存在一种可以在java中使用WMI类的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!