2

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.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
user3580199
  • 51
  • 1
  • 8

1 Answers1

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.

Community
  • 1
  • 1
Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325