WMI: The RPC server is unavailable. (Exception fro

2019-03-18 04:45发布

I'm using the following code to connect to remote machine using 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. (Exception from 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

Does anyone has an idea what is happening?

Thanks in advance,
Vasyl

标签: c# .net wmi
3条回答
男人必须洒脱
2楼-- · 2019-03-18 04:55

Also, You need to enable Windows Management Instrumentation (WMI) rule in windows firewall.

1] Windows Firewall.
2] Allow app or feature through windows firewall.
3] Enable Privilege for Windows Management Instrumentation(WMI).

查看更多
对你真心纯属浪费
3楼-- · 2019-03-18 05:05

Still you have problem then follow below link may help you.

Connecting to WMI Remotely

I facing this issue even my all firewall is off.

Below command run and my problem is solved.

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

  2. netsh advfirewall firewall add rule dir=in name="DCOM" program=%systemroot%\system32\svchost.exe service=rpcss action=allow protocol=TCP localport=135

  3. netsh advfirewall firewall add rule dir=in name ="WMI" program=%systemroot%\system32\svchost.exe service=winmgmt action = allow protocol=TCP localport=any

  4. netsh advfirewall firewall add rule dir=in name ="UnsecApp" program=%systemroot%\system32\wbem\unsecapp.exe action=allow

  5. netsh advfirewall firewall add rule dir=out name ="WMI_OUT" program=%systemroot%\system32\svchost.exe service=winmgmt action=allow protocol=TCP localport=any

查看更多
看我几分像从前
4楼-- · 2019-03-18 05:10

If you under Win7 you must run app as an administrator. You can also try different values for connOptions.Impersonation property. Did you open RPC port on a remote machine? Try turning off firewall altogeter on both machines.

查看更多
登录 后发表回答