我正在尝试将远程Windows Server 2012计算机与wmi4j连接但我得到了#34;访问被拒绝"错误。但我可以使用WMI Explorer 2016程序成功连接此远程计算机。
这是代码;
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
编辑: 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)