Provides access to local and remote processes and enables you to start and stop local system processes.
See Also: Process Members
Starting with the .NET Framework version 2.0, the ability to reference performance counter data on other computers has been eliminated for many of the .NET Framework methods and properties. This change was made to improve performance and to enable non-administrators to use the System.Diagnostics.Process class. As a result, some applications that did not get exceptions in earlier versions of the .NET Framework may now get a NotSupportedException. The methods and properties affected are too numerous to list here, but the exception information has been added to the affected member topics.
A System.Diagnostics.Process component provides access to a process that is running on a computer. A process, in the simplest terms, is a running application. A thread is the basic unit to which the operating system allocates processor time. A thread can execute any part of the code of the process, including parts currently being executed by another thread.
The System.Diagnostics.Process component is a useful tool for starting, stopping, controlling, and monitoring applications. Using the System.Diagnostics.Process component, you can obtain a list of the processes that are running, or you can start a new process. A System.Diagnostics.Process component is used to access system processes. After a System.Diagnostics.Process component has been initialized, it can be used to obtain information about the running process. Such information includes the set of threads, the loaded modules (.dll and .exe files), and performance information such as the amount of memory the process is using.
A 32-bit processes cannot access the modules of a 64-bit process. If you try to get information about a 64-bit process from a 32-bit process, you will get a System.ComponentModel.Win32Exception exception.
If you have a path variable declared in your system using quotes, you must fully qualify that path when starting any process found in that location. Otherwise, the system will not find the path. For example, if c:\mypath is not in your path, and you add it using quotation marks: path = %path%;"c:\mypath", you must fully qualify any process in c:\mypath when starting it.
The process component obtains information about a group of properties all at once. After the System.Diagnostics.Process component has obtained information about one member of any group, it will cache the values for the other properties in that group and not obtain new information about the other members of the group until you call the Process.Refresh method. Therefore, a property value is not guaranteed to be any newer than the last call to the Process.Refresh method. The group breakdowns are operating-system dependent.
A system process is uniquely identified on the system by its process identifier. Like many Windows resources, a process is also identified by its handle, which might not be unique on the computer. A handle is the generic term for an identifier of a resource. The operating system persists the process handle, which is accessed through the Process.Handle property of the System.Diagnostics.Process component, even when the process has exited. Thus, you can get the process's administrative information, such as the Process.ExitCode (usually either zero for success or a nonzero error code) and the Process.ExitTime. Handles are an extremely valuable resource, so leaking handles is more virulent than leaking memory.
This class contains a link demand and an inheritance demand at the class level that applies to all members. A System.Security.SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see Link Demands and Inheritance Demands.