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

我正在使用以下代码使用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(); 

我收到以下exception:RPC服务器不可用。 (来自HRESULT的exception:0x800706BA)

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

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

尝试过Wbemtest工具,结果相同

有谁知道发生了什么?

提前致谢,
瓦西利·

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

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

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

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

远程连接到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