[英]WMI: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) throws when try to connect to remote machine
I'm using the following code to connect to remote machine using WMI: 我正在使用以下代码使用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();
I'm getting the following exception: The RPC server is unavailable. 我收到以下异常:RPC服务器不可用。 (Exception from HRESULT: 0x800706BA)
(HRESULT异常:0x800706BA)
Checked all steps described in this knowledgebase article , everything is OK on remote machine. 检查了本知识库文章中描述的所有步骤,远程计算机上的一切正常。
User is Administrator on remote machine. 用户是远程计算机上的管理员。
Tried Wbemtest tool, the same result 尝试过Wbemtest工具,结果相同
Does anyone has an idea what is happening? 有谁知道发生了什么?
If you under Win7 you must run app as an administrator. 如果您在Win7下,则必须以管理员身份运行应用程序。 You can also try different values for connOptions.Impersonation property.
您还可以为connOptions.Impersonation属性尝试不同的值。 Did you open RPC port on a remote machine?
你在远程机器上打开RPC端口了吗? Try turning off firewall altogeter on both machines.
尝试在两台计算机上关闭防火墙altogeter。
Also, You need to enable Windows Management Instrumentation (WMI) rule in windows firewall. 此外,您需要在Windows防火墙中启用Windows Management Instrumentation(WMI)规则。
1] Windows Firewall.
1] Windows防火墙。
2] Allow app or feature through windows firewall.2]通过Windows防火墙允许应用程序或功能。
3] Enable Privilege for Windows Management Instrumentation(WMI).3]为Windows Management Instrumentation(WMI)启用权限。
To enable or disable WMI rule using Windows firewall 使用Windows防火墙启用或禁用WMI规则
- In the Control Panel , click Security and then click Windows Firewall.
在控制面板中 ,单击安全性 ,然后单击Windows防火墙。
- Click Change Settings and then click the Exceptions tab.
单击“ 更改设置” ,然后单击“例外”选项卡。
- In the Exceptions window , select the check box for Windows Management Instrumentation (WMI) to enable WMI traffic through the firewall .
在“ 例外”窗口中 ,选中Windows Management Instrumentation(WMI)的复选框以启用通过防火墙的 WMI流量。
To disable WMI traffic , clear the check box.
要禁用WMI流量 ,请清除该复选框。
You can also enable or disable WMI traffic through the firewall at the command prompt. 您还可以在命令提示符下通过防火墙启用或禁用WMI流量。
To enable or disable WMI traffic at command prompt using WMI rule group 使用WMI规则组在命令提示符下 启用或禁用WMI流量
Use the following commands at a command prompt. 在命令提示符处使用以下命令。 Type the following to enable WMI traffic through the firewall.
键入以下内容以通过防火墙启用WMI流量。
netsh advfirewall firewall set rule group="windows management instrumentation (wmi)" new enable=yes
Type the following command to disable WMI traffic through the firewall. 键入以下命令以禁用通过防火墙的WMI流量。
netsh advfirewall firewall set rule group="windows management instrumentation (wmi)" new enable=no
Still you have problem then follow below link may help you. 仍然有问题,然后按照以下链接可能会帮助你。
Connecting to WMI Remotely 远程连接到WMI
I facing this issue even my all firewall is off . 即使我的所有防火墙都关闭,我也面临这个问题。
Below command run and my problem is solved. 命令运行下面,我的问题解决了。
netsh advfirewall firewall set rule group="windows management instrumentation (wmi)" new enable=yes
netsh advfirewall防火墙设置规则组=“windows管理工具(wmi)”new enable = yes
netsh advfirewall firewall add rule dir=in name="DCOM" program=%systemroot%\\system32\\svchost.exe service=rpcss action=allow protocol=TCP localport=135
netsh advfirewall防火墙添加规则dir = in name =“DCOM”program =%systemroot%\\ system32 \\ svchost.exe service = rpcss action = allow protocol = TCP localport = 135
netsh advfirewall firewall add rule dir=in name ="WMI" program=%systemroot%\\system32\\svchost.exe service=winmgmt action = allow protocol=TCP localport=any
netsh advfirewall防火墙添加规则dir = in name =“WMI”program =%systemroot%\\ system32 \\ svchost.exe service = winmgmt action = allow protocol = TCP localport = any
netsh advfirewall firewall add rule dir=in name ="UnsecApp" program=%systemroot%\\system32\\wbem\\unsecapp.exe action=allow
netsh advfirewall防火墙添加规则dir = in name =“UnsecApp”program =%systemroot%\\ system32 \\ wbem \\ unsecapp.exe action = allow
netsh advfirewall firewall add rule dir=out name ="WMI_OUT" program=%systemroot%\\system32\\svchost.exe service=winmgmt action=allow protocol=TCP localport=any
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.