最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

codeigniter - Does there exist a way by which i can use WMI classes in java - Stack Overflow

programmeradmin4浏览0评论

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???

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???

Share Improve this question asked Jun 9, 2011 at 5:47 amodamod 4,26210 gold badges50 silver badges76 bronze badges
Add a comment  | 

7 Answers 7

Reset to default 7

JavaScript and Java aren't the same thing.

JavaScript

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 is a small library to enable Java to make general WMI queries. It seems to be available here

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 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.

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.

For the scripting language: Download Scriptomatic 2.0 and let the wizard create WMI code for VBScript, JScript, Perl, and Python. Here is something similar for Powershell.

I have successfully used WMI through JACOB

JInterop is a good option for WMI operations in java.

You might want to check J-Interop too. Here's a nice example: http://www.vijaykandy.com/2009/09/windows-management-instrumentation-wmi-from-java/

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

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

It is very easy to use:

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

评论列表(0)

  1. 暂无评论