Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
467 views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...