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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 20:11:26  来源:igfitidea点击:

Does there exist a way by which i can use WMI classes in java

codeigniterjavajavascriptpythonperl

提问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 实现。还有一个通用 WBEMJava 实现,它将在某种程度上与 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 finnw

I have successfully used WMI through JACOB

我已经通过JACOB成功使用了 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 nIKUNJ

JInteropis a good option for WMI operations in java.

JInterop是 Java 中 WMI 操作的不错选择。

回答by xarlie

回答by Snow

JWMI performing WMI operations by creating and executing vb scripts with the relevant queries.
I am using J-Interopwhich is an open source and a good option.
There are also JACOB, J-Integraand EZ Jcom.

JWMI 通过使用相关查询创建和执行 vb 脚本来执行 WMI 操作。
我正在使用J-Interop,它是一个开源且不错的选择。
还有JACOBJ-IntegraEZ Jcom

回答by profesor_falken

In order to perform WMI queries I recommend you my library WMI4Java.

为了执行 WMI 查询,我向您推荐我的库WMI4Java

It is very easy to use:

这是非常容易使用:

Map<String, String> wmiObjectProperties =   
    WMI4Java.get().getWMIObject("Win32_BIOS");