none
how to provide system.diagnostics.performancecounter impersonation through c#? RRS feed

  • Question

  • i have used the following code,
    static void Main(string[] args)
    {

    PerformanceCounterCategory cat = new PerformanceCounterCategory("Processor", "172.16.2.171");
    List<PerformanceCounter> counters = new List<PerformanceCounter>();
    foreach (string instance in cat.GetInstanceNames())
    counters.Add(new PerformanceCounter("Processor", "% Processor Time", instance, "172.16.2.171"));
    for (int i = 0; i < 10000; i++)
    {
    foreach (PerformanceCounter counter in counters)
    Console.Write(counter.NextValue() + " ");
    }

    }

    it results the "Access is Denied Error", the remote system has the credentials suchas domainname, username, password . how can i provide credentials in performancecounter class to obtain the remote system performance
    • Moved by Bob Shen Monday, May 6, 2013 7:53 AM
    Saturday, May 4, 2013 12:31 PM

Answers

All replies

  • Hi Gomathi,

    Welcome to the MSDN Forum.

    Would you like to try this KB: http://support.microsoft.com/kb/246758 

    This article describes how to use Performance Monitor and the Datalog.exe file that is included with Microsoft Windows NT 4.0 Resource Kit to log data and generate alerts on a remote computer without having to log on to it.

    I hope this will be helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, May 7, 2013 9:36 AM
    Moderator
  • Add the user account which runs the application to the  Performance Monitor Users group on the remote machine.
    Wednesday, May 15, 2013 6:51 PM
  • Oops! I accidentally clicked the Vote button. I was looking for a button that would mark the answer as completely useless...  NT 4 != helpful.

    Thursday, November 13, 2014 9:02 PM