System.Management.ManagementClass - access denied
Posted on 2005-04-12
I have an app which uses System.Management.ManagementClass to retrieve local hardware information, like the serial number of a hard drive or mac address of a network adapter. This worked great until, I think, WinXP SP2 was installed. Now, I get an "access denied" exception thrown, even when I'm logged in as administrator. I presume it's SP2 tightened security. Is there a setting somewhere where I can allow this?
here's some example code:
public static string GetProcessor()
ManagementClass managment = new ManagementClass("Win32_Processor");
ManagementObjectCollection processors = managment.GetInstances();
foreach(ManagementObject processor in processors) // "Access Denied" exception is thrown when enumeration is tried.