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"];
      }
}

colemaj1Asked:
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

http://www.vbcity.com/forums/topic.asp?tid=94870&page=2&#RID305940

HTH
Andy
0
 
eternal_21Commented:
Sorry I don't have any suggestions, but I ran your sample code under SP2, and it worked fine...
0
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.