0

I've been looking around for how to find the name of a process object gotten using System.Diagnostics.Process.GetProcesses (for instance, for the process firefox, 'Firefox') , and haven't been able to find anything. I've tried using MainWindowTitle, but instead of returning 'Firefox' it returns the name of the current tab, as that's what Firefox names it's window. Is there any way to find the actual display name of a process?

ejj28
  • 88
  • 2
  • 12
  • The `Process` class has the members that it has. The `ProcessName` property is the obvious candidate. If you actually want the friendly name displayed in Task Manager then that information is not provided by the `Process` class. Without having looked into it, I'd imagine that that information could be accessed using WMI, which exposes a lot of detailed system information. – jmcilhinney Aug 23 '18 at 01:19
  • Yeah, the names displayed in task manager are what I'm after. I'll give WMI a look – ejj28 Aug 23 '18 at 01:33
  • `Dim FireFoxProcesses As Process() = Process.GetProcessesByName("firefox")`. The main process is the only one which has a non empty `MainWindowTitle` (not necessarily `Process(0)`). The Window title will be the name (or Title, as you want to call it) of the currently selected Tab. – Jimi Aug 23 '18 at 04:50
  • `Process.GetProcesses()` gives back the list of all *visible* processes (those that have a `ProcessName`). Same as TaskManager. If you are looking for the *Windowed* Processes, those are all the Processes which have a non-zero `MainWindowHandle`. – Jimi Aug 23 '18 at 05:17
  • Yeah, I'm looking for the titles of the Windowed processes. I figured out finding which processes are windowed a while ago, but I still can't figure out how to get the proper display name, MainWindowTitle is close but not quite good enough – ejj28 Aug 24 '18 at 00:03

1 Answers1

-1
For Each p As Process In Process.GetProcesses()
    Debug.WriteLine(p.ProcessName)
Next

This might work, but is untested. https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.processname

StackDoubleFlow
  • 323
  • 4
  • 12