I am trying to connect to a remote computer using java and Jacob to get the WMI information about the remote computer.
For localhost, I use the code below and it works fine.
String host = "localhost"; String connectStr = String.format("winmgmts:\\\\%s\\root\\CIMV2", host); ActiveXComponent axWMI = new ActiveXComponent(connectStr);
But if I change localhost to another ip / hostname, I got the following error:
Exception in thread "main" com.jacob.com.ComFailException: Can't find moniker at com.jacob.com.Dispatch.createInstanceNative(Native Method) at com.jacob.com.Dispatch.<init>(Dispatch.java:99) at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58) at easyticket.classes.WmiExtended.main(WmiExtended.java:28)
and the line that throws the exception:
ActiveXComponent axWMI = new ActiveXComponent(connectStr);
EDIT
I tried passing username / password using WbemScripting
String host = "192.168.7.106"; ActiveXComponent axWMI = new ActiveXComponent("WbemScripting.SWbemLocator"); axWMI.invoke("ConnectServer", new Variant(host+",\"root\\cimv2\",\"username\",\"password\""));
but I got this error:
Exception in thread "main" com.jacob.com.ComFailException: Invoke of: ConnectServer Source: SWbemLocator Description: The RPC server is unavailable.
How can i solve this? How can I pass a username / password, and if I need a domain ???
I am using Windows 8 and I am trying to connect to win8 / win7 / winxp / win2003 computers.
Marcx source share