繁体   English   中英

WMI:RPC服务器不可用。 (尝试连接到远程计算机时抛出HRESULT异常:0x800706BA)

[英]WMI: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) throws when try to connect to remote machine

我正在使用以下代码使用WMI连接到远程计算机:

   ConnectionOptions connOptions = new ConnectionOptions();
            connOptions.Impersonation = ImpersonationLevel.Impersonate;
            connOptions.EnablePrivileges = true;
            connOptions.Username = "admin";
            connOptions.Password = "password";
            ManagementScope scope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", remoteMachine), connOptions);
            scope.Connect();

我收到以下异常:RPC服务器不可用。 (HRESULT异常:0x800706BA)

检查了本知识库文章中描述的所有步骤,远程计算机上的一切正常。

用户是远程计算机上的管理员。

尝试过Wbemtest工具,结果相同

有谁知道发生了什么?

如果您在Win7下,则必须以管理员身份运行应用程序。 您还可以为connOptions.Impersonation属性尝试不同的值。 你在远程机器上打开RPC端口了吗? 尝试在两台计算机上关闭防火墙altogeter。

此外,您需要在Windows防火墙中启用Windows Management Instrumentation(WMI)规则。

1] Windows防火墙。
2]通过Windows防火墙允许应用程序或功能。
3]为Windows Management Instrumentation(WMI)启用权限。

使用Windows防火墙启用或禁用WMI规则

  1. 控制面板中 ,单击安全性 ,然后单击Windows防火墙。
  2. 单击“ 更改设置” ,然后单击“例外”选项卡。
  3. 在“ 例外”窗口中 ,选中Windows Management Instrumentation(WMI)的复选框以启用通过防火墙的 WMI流量。

禁用WMI流量 ,请清除该复选框。

您还可以在命令提示符下通过防火墙启用或禁用WMI流量。

使用WMI规则组在命令提示符下 启用或禁用WMI流量

在命令提示符处使用以下命令。 键入以下内容以通过防火墙启用WMI流量。

netsh advfirewall firewall set rule group="windows management instrumentation (wmi)" new enable=yes

键入以下命令以禁用通过防火墙的WMI流量。

netsh advfirewall firewall set rule group="windows management instrumentation (wmi)" new enable=no

仍然有问题,然后按照以下链接可能会帮助你。

远程连接到WMI

即使我的所有防火墙都关闭,我也面临这个问题。

命令运行下面,我的问题解决了。

  1. netsh advfirewall防火墙设置规则组=“windows管理工具(wmi)”new enable = yes

  2. netsh advfirewall防火墙添加规则dir = in name =“DCOM”program =%systemroot%\\ system32 \\ svchost.exe service = rpcss action = allow protocol = TCP localport = 135

  3. netsh advfirewall防火墙添加规则dir = in name =“WMI”program =%systemroot%\\ system32 \\ svchost.exe service = winmgmt action = allow protocol = TCP localport = any

  4. netsh advfirewall防火墙添加规则dir = in name =“UnsecApp”program =%systemroot%\\ system32 \\ wbem \\ unsecapp.exe action = allow

  5. netsh advfirewall防火墙添加规则dir = out name =“WMI_OUT”program =%systemroot%\\ system32 \\ svchost.exe service = winmgmt action = allow protocol = TCP localport = any

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM