Process Description Name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • g3rmanpride21
    New Member
    • Jul 2009
    • 2

    Process Description Name

    I'm currently working with this piece of code:


    Code:
    CheckedListBox1.Items.Clear()
    CheckedListBox1.DisplayMember = "ProcessName"
    Dim p As Process
    For Each p In Process.GetProcesses
    CheckedListBox1.Items.Add(p)
    Next

    But what it is doing is getting the actual .exe name of the process - example "dwm.exe".
    I want it to give the file description of the .exe - example instead of "dwm.exe" the description of dwm.exe is "Desktop Window Manager" and I want that file description to show up in the checkedliskbox instead of the .exe name.

    Is this possible to get a list of the running process and show the file description name instead of the .exe name?

    Please help!
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    Hi,

    I've been searching, but it seems there is no way to find the description of the processes running. It's not a property of Process. As you can't extract the full path of the process running, you also can't use the System.IO.FileI nfo.

    I think you have something in mind like the tasklist in the taskmanager. I think that list is created based on all open windows. Like I said, I don't think it can be done, but perhaps there is someone else who knows a solution.

    Cheers,

    Steven

    Comment

    • g3rmanpride21
      New Member
      • Jul 2009
      • 2

      #3
      Actually there is a way, I finally figured it out, here is the code if you are curious:


      Code:
       #
      For Each p As Process In Process.GetProcesses
      #
                  Try
      #
                      Dim ProcessFile = FileVersionInfo.GetVersionInfo(p.MainModule.FileName)
      #
                      CheckedListBox1.Items.Add(ProcessFile.FileDescription)
      #
                  Catch ex As System.ComponentModel.Win32Exception
      #
                      If ex.Message = "Access is denied" Then
      #
                      Else
      #
                          'error handling
      #
                      End If
      #
                  End Try
      #
              Next

      Comment

      • gbello97
        New Member
        • May 2014
        • 5

        #4
        i know this is late but how do you kill the process it found? thank you

        Comment

        • Luk3r
          Contributor
          • Jan 2014
          • 300

          #5
          gbello97, you should technically open a new question for your answer, but since the question has been asked we will let the mods move this around if needed:

          Code:
                  For Each p As Process In Process.GetProcesses  'loop through your processes
                      Try
                          If p.ProcessName.ToLower = "notepad" Then 'if the process name is notepad... then kill it
                              p.Kill() 'kill the process
                          End If
                      Catch ex As Exception
                          'do something here for the exception
                      End Try
                  Next
          Alternatively, you can remove the If..Then statement and kill every running process (not suggested).

          You can also simply loop through all processes, searching by process name, and kill each instance of that process:
          Code:
                  For Each p As Process In Process.GetProcessesByName("notepad") 'loop through processes for only a single process name
                      p.Kill() 'kill the process
                  Next

          Comment

          • gbello97
            New Member
            • May 2014
            • 5

            #6
            The code you gave me is not what I'm looking for. I want the code posted on this thread but I just wanna know how to kill the process if it's found. Thank you

            Comment

            • gbello97
              New Member
              • May 2014
              • 5

              #7
              I want to kill a process by its description.

              Comment

              • Luk3r
                Contributor
                • Jan 2014
                • 300

                #8
                Open a new thread and I'll be more than happy to help :)

                Comment

                • gbello97
                  New Member
                  • May 2014
                  • 5

                  #9
                  Ok how do I do that haha

                  Comment

                  Working...