System.Management.ManagementClass - access denied

Posted on 2005-04-12
Last Modified: 2008-01-09
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"];

Question by:colemaj1
    LVL 10

    Expert Comment

    Sorry I don't have any suggestions, but I ran your sample code under SP2, and it worked fine...
    LVL 10

    Accepted Solution

    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


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now