How to connect remote machine with wmi?

916 Views Asked by At

I am trying to connect remote windows server 2012 machine with wmi4j but I am getting "access denied" error. But I can connect successfully this remote machine with WMI Explorer 2016 program.

Here is code;

private static String server = "****";
private static String username = "**\\Administrator";
private static String password = "pass";
private static String namespace = "root\\cimv2";

SWbemLocator locator = new SWbemLocator(server,username,password,namespace);
SWbemServices services = locator.connectServer(); //this line throws exception

I also give all permissions (https://social.technet.microsoft.com/Forums/office/en-US/4f33837b-1cb1-4648-85b1-3ba87cbfe93e/wmi-remote-access-denied?forum=winserverManagement)

EDIT: Stacktrace;

cn.chenlichao.wmi4j.WMIException: Access is denied, please check whether the [domain-username-password] are correct. Also, if not already done please check the GETTING STARTED and FAQ sections in readme.htm. They provide information on how to correctly configure the Windows machine for DCOM access, so as to avoid such exceptions.  [0x00000005]
at cn.chenlichao.wmi4j.SWbemLocator.connectServer(SWbemLocator.java:165)
at cn.chenlichao.wmi4j.SWbemLocator.connectServer(SWbemLocator.java:177)
at com.mycompany.javacombridge.JACOB.main(JACOB.java:60)
0

There are 0 best solutions below