The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) when connecting to remote computer

1

I try to connect remote computer by using winforms c#.

My Code:

private void Form1_Load(object sender, EventArgs e)
{
    var connection = new ConnectionOptions();
    connection.Username = "xx";
    connection.Password = "xx";

    var scope = new ManagementScope("\\\\111.111.111.22:6000\\root\\CIMV2", connection);
    scope.Connect();   // Exception occurs here..
}

I get below Error in line scope.Connect();

Error:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Management.dll

Additional information: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

Any help will be appreciated.

c#
wmi
asked on Stack Overflow Apr 28, 2014 by user3580199 • edited Apr 28, 2014 by Patrick Hofman

1 Answer

2

I am pretty sure you did not run this application as administrator.

Thanks to UAC you need to run your application as administrator to get this to work.

See How do I force my .NET application to run as administrator? to read how to add a app.manifest to your application, forcing it to run as administrator.

answered on Stack Overflow Apr 28, 2014 by Patrick Hofman • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0