NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Process.GetProcessesByName (String, String)

Creates an array of Process components that are associated with process resources on a remote computer. These process resources share the specified process name.

[Visual Basic]
Overloads Public Shared Function GetProcessesByName( _
   ByVal processName As String, _
   ByVal machineName As String _
) As Process ()
[C#]
public static Process[] GetProcessesByName(
   string processName,
   string machineName
);
[C++]
public: static Process* GetProcessesByName(
   String* processName,
   String* machineName
) [];
[JScript]
public static function GetProcessesByName(
   processName : String,
   machineName : String
) : Process[];

Parameters

processName
The friendly name of the process.
machineName
[To be supplied.]

Return Value

An array of type Process that represents the process resources running the specified application or file.

Remarks

Use this method to create an array of new Process components and associate them with process resources that are all running the same executable file on the specified computer. The process resources must already exist on the specified computer, because GetProcessesByName does not create backend resources, but rather associates them with application-generated Process components. A processName can be specified for an executable that is not currently running on the computer, so the array could be empty when it returns from the method call.

The process name is a friendly name for the process, without the .exe extension or the path, such as "Outlook". GetProcessesByName is helpful for getting and manipulating all processes associated with the same executable file. For example, you can pass in an executable name as the processName parameter in order to shut down all running instances of that executable.

While a process Id is unique to a single process resource on the system, multiple processes on a computer can be running the application specified by the processName parameter. Therefore, GetProcessById will return one process at most, but GetProcessesByName returns an array containing all associated processes. You can query each of these processes in turn for their Id if you need to manipulate the process using standard API calls. You cannot access process resources through the process name alone, but once you have retrieved an array of Process components that have been associated with the process resources, you can start, terminate, and otherwise manipulate the backend resources.

Because the GetProcessesByName method is static (in Visual Basic Shared), you do not need to create an instance of the Process component before you call the method. You can call the method on the Process class itself.

If you do not specify a processName, an empty string ("") is assumed.

You can use this overload to get processes on the local computer as well as a remote computer. Use "." or an empty string ("") to specify the local computer. Another overload exists that uses the local computer by default.

You can only access processes on remote machines in order to view information, such as statistics, about the processes. Because of security restrictions, you cannot close, kill or start processes on remote machines. tech review: can you get exited event notifications?

See Also

Process Class | Process Members | System.Diagnostics Namespace | Process.GetProcessesByName Overload List | ProcessName | MachineName | GetProcessById | GetProcesses | GetCurrentProcess