Is there a way I can use WMI classes in java

Hi, I want to use WMI classes to find out information about the application and products. But the problem is that I want to use java or any scripting language like python, javascript or perl. I heard about JWMI, this may be an option. Can anyone help me in this regard?

+4
source share
7 answers

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.

+5
source

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

+2
source

I have successfully used WMI via JACOB

+2
source

JInterop is a good option for WMI operations in java.

+1
source
+1
source

JWMI performs WMI operations by creating and executing vb scripts with the corresponding requests.
I use J-Interop , which is open source and a good option.
There are also JACOB , J-Integra and EZ Jcom .

+1
source

To execute WMI requests, I recommend you my WMI4Java library.

It is very easy to use:

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

All Articles