Creates an array of new System.Diagnostics.Process components and associates them with all the process resources on the local computer that share the specified process name.
An array of type System.Diagnostics.Process that represents the process resources running the specified application or file.
Use this method to create an array of new System.Diagnostics.Process components and associate them with all the process resources that are running the same executable file on the local computer. The process resources must already exist on the computer, because Process.GetProcessesByName(string) does not create system resources but rather associates them with application-generated System.Diagnostics.Process components. A processName can be specified for an executable file that is not currently running on the local computer, so the array the method returns can be empty.
The process name is a friendly name for the process, such as Outlook, that does not include the .exe extension or the path. Process.GetProcessesByName(string) is helpful for getting and manipulating all the processes that are associated with the same executable file. For example, you can pass an executable file name as the processName parameter, in order to shut down all the running instances of that executable file.
Although a process Process.Id is unique to a single process resource on the system, multiple processes on the local computer can be running the application specified by the processName parameter. Therefore, Process.GetProcessById(int, string) returns one process at most, but Process.GetProcessesByName(string) returns an array containing all the associated processes. If you need to manipulate the process using standard API calls, you can query each of these processes in turn for its identifier. You cannot access process resources through the process name alone but, once you have retrieved an array of System.Diagnostics.Process components that have been associated with the process resources, you can start, terminate, and otherwise manipulate the system resources.