none
System.Diagnostics.Process object keeps throwing Access Denied win32 exceptions!!! RRS feed

  • Question

  • Hello, everyone.

    I am programming a very task manager-like program in c# and wpf. I am using system.diagnostics.process for getting all of my info about the processes. But I keep getting stopped by this (VERY frusturating) Win32 exception: Access Denied.

    And I'm going "WHY the HECK?" Why in the world would this be "Access Denied??!?" Is it somehow a security risk if I get the TotalProcessorTime of a Process object (Which is exactly what I was trying to do)? This makes NO sense.

    If you know why it's doing this, please respond. I just want to get a % CPU usage from a Process object. If task manager can do this so easily, why can't I?

    Thanks in advance. I'm glad there's a forum like this out there :-)

    Saturday, May 19, 2012 6:10 AM

Answers

  • Am assuming you are using Windows Vista  or Windows 7 with UAC enabled. You can try by either disabling UAC or running your process as an Administrator and it should work
    Saturday, May 19, 2012 9:28 AM
  • Hi Alex,

     These articles may be useful for you..

    http://www.philosophicalgeek.com/2009/01/03/determine-cpu-usage-of-current-process-c-and-c/

    http://www.codeproject.com/Articles/10258/How-to-get-CPU-usage-of-processes-and-threads


    Sai Kumar K http://www.santoshtechnologies.com http://saimaterial.wordpress.com


    Saturday, May 19, 2012 7:22 AM
  • Hi Alex,

    For getting system and process related information, you have to take help of Win32 APIs. Here some command lines are given, using WMI, you can integrate the same in c#.

    http://www.techish.net/windows/get-process-cpu-usage-using-wmi


    Regards, http://shwetamannjain.blogspot.com or https://shwetalodha.wordpress.com/

    Sunday, May 20, 2012 5:45 AM

All replies

  • Hi Alex,

     These articles may be useful for you..

    http://www.philosophicalgeek.com/2009/01/03/determine-cpu-usage-of-current-process-c-and-c/

    http://www.codeproject.com/Articles/10258/How-to-get-CPU-usage-of-processes-and-threads


    Sai Kumar K http://www.santoshtechnologies.com http://saimaterial.wordpress.com


    Saturday, May 19, 2012 7:22 AM
  • Am assuming you are using Windows Vista  or Windows 7 with UAC enabled. You can try by either disabling UAC or running your process as an Administrator and it should work
    Saturday, May 19, 2012 9:28 AM
  • Hi Alex,

    For getting system and process related information, you have to take help of Win32 APIs. Here some command lines are given, using WMI, you can integrate the same in c#.

    http://www.techish.net/windows/get-process-cpu-usage-using-wmi


    Regards, http://shwetamannjain.blogspot.com or https://shwetalodha.wordpress.com/

    Sunday, May 20, 2012 5:45 AM