[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1445
  • Last Modified:

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

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now