How to: Bind to Existing Processes
You can use the Process component as a connection between your application and the processes on your computer. You bind to an existing process by using the GetProcessesByName method to return an array of processes (in the form of Process component instances) associated with each running instance of the specified file name. The first element of the array will be the first instance of the running process that the method finds. If there is only one instance of the process, the index of 0 can be used to reference the single instance of the process. You can use each of these returned instances to manipulate the processes with which they are associated.
To bind to an existing process
Dim myProcesses() As Process
The following example shows how to call the GetProcessesByName method to add Notepad.exe to the process array.
myProcesses = Process.GetProcessesByName("Notepad")
myProcesses = Process.GetProcessesByName("Notepad");
Use the indexed property value to manipulate a single process in the array.
' Closes the first instance of Notepad in the process array. myProcesses(0).CloseMainWindow()
// Closes the first instance of Notepad in the process array. myProcesses.CloseMainWindow();