Javascript and Java are not the same thing.
Javascript
Javascript is available under the Windows Scripting Host (WSH). Using it is quite 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 that allows Java to create common WMI requests. It seems to be available here:
http://henryranch.net/software/jwmi-query-windows-wmi-from-java/
It also seems easy to use (although I'm not sure how strong or complete it is):
String name = getWMIValue("Select Name from Win32_ComputerSystem", "Name");
WBEM (Java)
WMI is an implementation of Microsoft Web Site Management (WBEM). There is also a Java implementation of general WBEM that will be compatible with WMI at some level:
http://wbemservices.sourceforge.net/
This may be the most complete true Java implementation you are about to find. If your needs exceed tiny scenarios (such as implementing a WBEM / WMI provider), you may need to examine this option.
source share