javascript 是否存在一种方法可以让我在 Java 中使用 WMI 类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6288580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does there exist a way by which i can use WMI classes in java
提问by amod
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???
嗨,我想使用 WMI 类来查找应用程序和产品信息。但问题是我想使用 java 或任何脚本语言,如 python、javascript 或 perl。我听说过 JWMI,它可能是一种选择。谁能帮我解决这个问题???
回答by Merlyn Morgan-Graham
JavaScript and Java aren't the same thing.
JavaScript 和 Java 不是一回事。
JavaScript
JavaScript
JavaScript is available under Windows Scripting Host (WSH). With it, it is fairly easy to access WMI:
JavaScript 在 Windows Scripting Host (WSH) 下可用。有了它,访问 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)
jWMI is a small library to enable Java to make general WMI queries. It seems to be available here
jWMI 是一个小型库,使 Java 能够进行常规 WMI 查询。这里好像可以用
http://henryranch.net/software/jwmi-query-windows-wmi-from-java/
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)
WBEM (Java)
WMI is a Microsoft implementation of Web Based Enterprise Management(WBEM). There is also a Java implementation of general WBEMwhich will be at some level compatible with WMI.
WMI 是基于 Web 的企业管理(WBEM)的 Microsoft 实现。还有一个通用 WBEM的Java 实现,它将在某种程度上与 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 实现。如果您的需求超出了微小的脚本编写(例如实现 WBEM/WMI 提供程序),那么您可能需要研究此选项。
回答by Ekkehard.Horner
For the scripting language: Download Scriptomatic 2.0and let the wizard create WMI code for VBScript, JScript, Perl, and Python. Hereis something similar for Powershell.
对于脚本语言:下载Scriptomatic 2.0并让向导为 VBScript、JScript、Perl 和 Python 创建 WMI 代码。这是 Powershell 的类似内容。
回答by xarlie
You might want to check J-Interoptoo. Here's a nice example: http://www.vijaykandy.com/2009/09/windows-management-instrumentation-wmi-from-java/
您可能也想检查J-Interop。这是一个很好的例子:http: //www.vijaykandy.com/2009/09/windows-management-instrumentation-wmi-from-java/