How do I get list of Process Names running, in VB.NET?
process, vb.net
Solution
I need to get a list of running processes, by name, and test if "processname" is a substring of the name.
You could use:
Dim procExists as Boolean = Process.GetProcesses().Any(Function(p) p.Name.Contains(processName))
This will look through all of the processes, and set the `procExists` value to True if any process which contains `processName` exists in the currently executing processes. This should handle the existence of the unknown version number as well as the `*32` that may occur if you're running on a 64bit OS (that's the WOW64 flag saying that it's a 32bit process running on a 64bit OS).
Problem
I am trying to find out if an instance of an application (not vb.net) is already running - because I will want to start it but I don't want to start it if it is already running. I have found a solution to check if a process is running: ``` Dim proc As Integer = Process.GetProcessesByName(ProcessName).GetUpperBound(0) + 1 ``` and return True if >=1 (or just the process number). My problem is, this is a third-party application, and its process name is not just a name but it contains a version number (which I may not know at run time), and it also seems to add a *32 (so probably a *64 if it is installed in x64 ?). I need to get a list of running processes, by name, and test if "processname" is a substring of the name. But I haven't been successful in getting a list of names, only process id's.