如何使用wmi连接远程计算机?

时间:2016-08-12 07:36:15

标签: java wmi windows-server-2012 j-interop

我正在尝试将远程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

我还授予所有权限(https://social.technet.microsoft.com/Forums/office/en-US/4f33837b-1cb1-4648-85b1-3ba87cbfe93e/wmi-remote-access-denied?forum=winserverManagement

编辑: 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 个答案:

没有答案