I am working on WMI. I want to access remote system information. The following code works for loopback or localhost, but when I try to access a remote computer, it shows the following exception error:
Access is denied. (Exception from HRESULT: 0X8005 (E_ACCESSDENIED))
When the switch is used between 2 systems.
and
The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
When both systems are directly connected.
OS on both systems: Windows Service Pack 2.
Firewalls = blocked.
Remote procedure = start.
Tool: .NET Visual Studio 2008 C #
the 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())
{
foreach (PropertyData aProperty in obj.Properties)
{
listBox1.Items.Add(aProperty.Name.ToString() + " : " + aProperty.Value);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
source
share