System.Management.ManagementClass - access denied

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.
           return (string)processor["Description"];

Who is Participating?
heintalusConnect With a Mentor Commented:
XP SP2 locks down RPC by default which the ManagementClass uses to retrieve information, I'd suggest looking at the firewall settings for RPC.

Check out the link below where I've posted some links that might help

Sorry I don't have any suggestions, but I ran your sample code under SP2, and it worked fine...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.