locked
How To Get The Process Description Based On Process ID? RRS feed

  • Question

  • Hi all,
    I have tried in two ways to get process description
    Solution1:-
    code:- Process proc = Process.GetProcessById(pid);
    string process_description= proc.MainModule.FileVersionInfo.FileDescription
    Problem:-when we trying to access the MainModule property for some processes 0(idle), 4(system) or services(Having admin acces rights)
    (most likely those running under SYSTEM credentials) on which user don't have the permission leads to win32 ACCESS DENIED EXCEPTION.
    Solution 2:-
    code :- string process_description=FileVersionInfo.GetVersionInfo(modulePath).FileDescription;
    Problem :-Unable to get process decription if it was not mention in the properties of exe file or process which have admin rights .
    For example:if process is google chrome.
    ImageName:-chrome.exe         Description :Google chrome 
    I want to get the description not the Image Name. 

    Can any one share your ideas how to get process description in taskmanager for particular process id.

    Thanks,

    Padma Yeddula.

    Thursday, July 10, 2014 7:16 AM

Answers

  • "But problem is, if an executable is having an admin access rights then  i am  getting the modulepath as empty as a result unable to get the process description from above code .how can i get out from this case."

    It's not possible, there's no documented/supported way of obtaining the module path of a process you don't have access to.

    • Proposed as answer by Ioana Vasilescu Friday, July 11, 2014 9:42 AM
    • Marked as answer by Anne Jing Thursday, July 17, 2014 6:42 AM
    Thursday, July 10, 2014 12:36 PM

All replies

  • Hi

    Thanks for the reply.

    I have verified but in above link also it is mentioned to use below code

    string name = currentProc.ProcessName;

    Actually here  ProcessName gives the EXE file name(for example i,e chrome.exe but not Google chrome)

    I want the description of process but not the process name

    Thanks,

    Padma Yeddula


    Padma Yeddula


    Thursday, July 10, 2014 8:51 AM
  • "I want the description of process but not the process name"

    There's no such thing as description of a process, only files have description. Task Manager extract the description from the executable file, if a description is not available in the file then it simply uses the file name as description.

    Thursday, July 10, 2014 8:55 AM
  • Hi Mike Danes,

    Thanks for your reply.

    Yes ,what you are telling is correct extracting the description from executable file  can be achieved with the help of below code

    string process_description=FileVersionInfo.GetVersionInfo(modulePath).FileDescription;

    But problem is, if an executable is having an admin access rights then  i am  getting the modulepath as empty as a result unable to get the process description from above code .how can i get out from this case.

    Thanks

    Padma Yeddula


    Padma Yeddula


    Thursday, July 10, 2014 9:18 AM
  • Use GetVersionInfo . Than check the FileDescription and or ProductName properties .
    Thursday, July 10, 2014 10:41 AM
  • "But problem is, if an executable is having an admin access rights then  i am  getting the modulepath as empty as a result unable to get the process description from above code .how can i get out from this case."

    It's not possible, there's no documented/supported way of obtaining the module path of a process you don't have access to.

    • Proposed as answer by Ioana Vasilescu Friday, July 11, 2014 9:42 AM
    • Marked as answer by Anne Jing Thursday, July 17, 2014 6:42 AM
    Thursday, July 10, 2014 12:36 PM
  • Hi  Mike Danes,

    Thanks.

    Ok then . I will be take the process name itself instead of description if module path is empty.


    Padma Yeddula

    Friday, July 11, 2014 4:29 AM