I am working on WMI. I want to access remote system information. The following code is working for loopback or on local host but when I try to access the remote machine it shows the following exception error:
Access is denied. (Exception from HRESULT:0X8005(E_ACCESSDENIED))
When switch is used between 2 systems.
and
The RPC server Is unavailable. (Exception from HRESULT: 0x800706BA)
When both the systems are directly connected.
OS on both systems: Windows Service Pack 2.
Firewalls = blocked.
Remote procedure service = running.
Tool : .NET Visual Studio 2008 C#
Code:
try
{
ConnectionOptions _Options = new ConnectionOptions();
ManagementPath _Path = new ManagementPath(s);
ManagementScope _Scope = new ManagementScope(_Path, _Options);
_Scope.Connect();
ManagementObjectSearcher srcd = new ManagementObjectSearcher("select * from Win32_DisplayConfiguration");
foreach (ManagementObject obj in srcd.Get())
{
//listBox5.Items.Add(obj.Properties.ToString());
foreach (PropertyData aProperty in obj.Properties)
{
listBox1.Items.Add(aProperty.Name.ToString() + " : " + aProperty.Value);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}