mscorlib(4.0.0.0) API with additions
System.Diagnostics.Process Class Reference

Provides access to local and remote processes and enables you to start and stop local system processes.To browse the .NET Framework source code for this type, see the Reference Source. More...

Inheritance diagram for System.Diagnostics.Process:
[legend]
Collaboration diagram for System.Diagnostics.Process:
[legend]

Public Member Functions

 Process ()
 Initializes a new instance of the T:System.Diagnostics.Process class. More...
 
bool CloseMainWindow ()
 Closes a process that has a user interface by sending a close message to its main window. More...
 
void Close ()
 Frees all the resources that are associated with this component. More...
 
void Refresh ()
 Discards any information about the associated process that has been cached inside the process component. More...
 
bool Start ()
 Starts (or reuses) the process resource that is specified by the P:System.Diagnostics.Process.StartInfo property of this T:System.Diagnostics.Process component and associates it with the component. More...
 
void Kill ()
 Immediately stops the associated process. More...
 
override string ToString ()
 Formats the process's name as a string, combined with the parent component type, if applicable. More...
 
bool WaitForExit (int milliseconds)
 Instructs the T:System.Diagnostics.Process component to wait the specified number of milliseconds for the associated process to exit. More...
 
void WaitForExit ()
 Instructs the T:System.Diagnostics.Process component to wait indefinitely for the associated process to exit. More...
 
bool WaitForInputIdle (int milliseconds)
 Causes the T:System.Diagnostics.Process component to wait the specified number of milliseconds for the associated process to enter an idle state. This overload applies only to processes with a user interface and, therefore, a message loop. More...
 
bool WaitForInputIdle ()
 Causes the T:System.Diagnostics.Process component to wait indefinitely for the associated process to enter an idle state. This overload applies only to processes with a user interface and, therefore, a message loop. More...
 
void BeginOutputReadLine ()
 Begins asynchronous read operations on the redirected P:System.Diagnostics.Process.StandardOutput stream of the application. More...
 
void BeginErrorReadLine ()
 Begins asynchronous read operations on the redirected P:System.Diagnostics.Process.StandardError stream of the application. More...
 
void CancelOutputRead ()
 Cancels the asynchronous read operation on the redirected P:System.Diagnostics.Process.StandardOutput stream of an application. More...
 
void CancelErrorRead ()
 Cancels the asynchronous read operation on the redirected P:System.Diagnostics.Process.StandardError stream of an application. More...
 
- Public Member Functions inherited from System.ComponentModel.Component
void Dispose ()
 Releases all resources used by the T:System.ComponentModel.Component. More...
 
override string ToString ()
 Returns a T:System.String containing the name of the T:System.ComponentModel.Component, if any. This method should not be overridden. More...
 
- Public Member Functions inherited from System.MarshalByRefObject
object GetLifetimeService ()
 Retrieves the current lifetime service object that controls the lifetime policy for this instance. More...
 
virtual object InitializeLifetimeService ()
 Obtains a lifetime service object to control the lifetime policy for this instance. More...
 
virtual ObjRef CreateObjRef (Type requestedType)
 Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. More...
 

Static Public Member Functions

static void EnterDebugMode ()
 Puts a T:System.Diagnostics.Process component in state to interact with operating system processes that run in a special mode by enabling the native property SeDebugPrivilege on the current thread. More...
 
static void LeaveDebugMode ()
 Takes a T:System.Diagnostics.Process component out of the state that lets it interact with operating system processes that run in a special mode. More...
 
static Process GetProcessById (int processId, string machineName)
 Returns a new T:System.Diagnostics.Process component, given a process identifier and the name of a computer on the network. More...
 
static Process GetProcessById (int processId)
 Returns a new T:System.Diagnostics.Process component, given the identifier of a process on the local computer. More...
 
static Process [] GetProcessesByName (string processName)
 Creates an array of new T:System.Diagnostics.Process components and associates them with all the process resources on the local computer that share the specified process name. More...
 
static Process [] GetProcessesByName (string processName, string machineName)
 Creates an array of new T:System.Diagnostics.Process components and associates them with all the process resources on a remote computer that share the specified process name. More...
 
static Process [] GetProcesses ()
 Creates a new T:System.Diagnostics.Process component for each process resource on the local computer. More...
 
static Process [] GetProcesses (string machineName)
 Creates a new T:System.Diagnostics.Process component for each process resource on the specified computer. More...
 
static Process GetCurrentProcess ()
 Gets a new T:System.Diagnostics.Process component and associates it with the currently active process. More...
 
static Process Start (string fileName, string userName, SecureString password, string domain)
 Starts a process resource by specifying the name of an application, a user name, a password, and a domain and associates the resource with a new T:System.Diagnostics.Process component. More...
 
static Process Start (string fileName, string arguments, string userName, SecureString password, string domain)
 Starts a process resource by specifying the name of an application, a set of command-line arguments, a user name, a password, and a domain and associates the resource with a new T:System.Diagnostics.Process component. More...
 
static Process Start (string fileName)
 Starts a process resource by specifying the name of a document or application file and associates the resource with a new T:System.Diagnostics.Process component. More...
 
static Process Start (string fileName, string arguments)
 Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new T:System.Diagnostics.Process component. More...
 
static Process Start (ProcessStartInfo startInfo)
 Starts the process resource that is specified by the parameter containing process start information (for example, the file name of the process to start) and associates the resource with a new T:System.Diagnostics.Process component. More...
 

Protected Member Functions

override void Dispose (bool disposing)
 Release all resources used by this process. More...
 
void OnExited ()
 Raises the E:System.Diagnostics.Process.Exited event. More...
 
- Protected Member Functions inherited from System.ComponentModel.Component
virtual object GetService (Type service)
 Returns an object that represents a service provided by the T:System.ComponentModel.Component or by its T:System.ComponentModel.Container. More...
 
- Protected Member Functions inherited from System.MarshalByRefObject
MarshalByRefObject MemberwiseClone (bool cloneIdentity)
 Creates a shallow copy of the current T:System.MarshalByRefObject object. More...
 

Properties

int BasePriority [get]
 Gets the base priority of the associated process. More...
 
int ExitCode [get]
 Gets the value that the associated process specified when it terminated. More...
 
bool? HasExited [get]
 Gets a value indicating whether the associated process has been terminated. More...
 
DateTime ExitTime [get]
 Gets the time that the associated process exited. More...
 
IntPtr Handle [get]
 Gets the native handle of the associated process. More...
 
SafeProcessHandle SafeHandle [get]
 Gets the native handle to this process. More...
 
int HandleCount [get]
 Gets the number of handles opened by the process. More...
 
int Id [get]
 Gets the unique identifier for the associated process. More...
 
string MachineName [get]
 Gets the name of the computer the associated process is running on. More...
 
IntPtr MainWindowHandle [get]
 Gets the window handle of the main window of the associated process. More...
 
string MainWindowTitle [get]
 Gets the caption of the main window of the process. More...
 
ProcessModule MainModule [get]
 Gets the main module for the associated process. More...
 
IntPtr MaxWorkingSet [get, set]
 Gets or sets the maximum allowable working set size, in bytes, for the associated process. More...
 
IntPtr MinWorkingSet [get, set]
 Gets or sets the minimum allowable working set size, in bytes, for the associated process. More...
 
ProcessModuleCollection Modules [get]
 Gets the modules that have been loaded by the associated process. More...
 
int NonpagedSystemMemorySize [get]
 Gets the amount of nonpaged system memory, in bytes, allocated for the associated process. More...
 
long NonpagedSystemMemorySize64 [get]
 Gets the amount of nonpaged system memory, in bytes, allocated for the associated process. More...
 
int PagedMemorySize [get]
 Gets the amount of paged memory, in bytes, allocated for the associated process. More...
 
long PagedMemorySize64 [get]
 Gets the amount of paged memory, in bytes, allocated for the associated process. More...
 
int PagedSystemMemorySize [get]
 Gets the amount of pageable system memory, in bytes, allocated for the associated process. More...
 
long PagedSystemMemorySize64 [get]
 Gets the amount of pageable system memory, in bytes, allocated for the associated process. More...
 
int PeakPagedMemorySize [get]
 Gets the maximum amount of memory in the virtual memory paging file, in bytes, used by the associated process. More...
 
long PeakPagedMemorySize64 [get]
 Gets the maximum amount of memory in the virtual memory paging file, in bytes, used by the associated process. More...
 
int PeakWorkingSet [get]
 Gets the peak working set size for the associated process, in bytes. More...
 
long PeakWorkingSet64 [get]
 Gets the maximum amount of physical memory, in bytes, used by the associated process. More...
 
int PeakVirtualMemorySize [get]
 Gets the maximum amount of virtual memory, in bytes, used by the associated process. More...
 
long PeakVirtualMemorySize64 [get]
 Gets the maximum amount of virtual memory, in bytes, used by the associated process. More...
 
bool PriorityBoostEnabled [get, set]
 Gets or sets a value indicating whether the associated process priority should temporarily be boosted by the operating system when the main window has the focus. More...
 
ProcessPriorityClass PriorityClass [get, set]
 Gets or sets the overall priority category for the associated process. More...
 
int PrivateMemorySize [get]
 Gets the amount of private memory, in bytes, allocated for the associated process. More...
 
long PrivateMemorySize64 [get]
 Gets the amount of private memory, in bytes, allocated for the associated process. More...
 
TimeSpan PrivilegedProcessorTime [get]
 Gets the privileged processor time for this process. More...
 
string ProcessName [get]
 Gets the name of the process. More...
 
IntPtr ProcessorAffinity [get, set]
 Gets or sets the processors on which the threads in this process can be scheduled to run. More...
 
bool Responding [get]
 Gets a value indicating whether the user interface of the process is responding. More...
 
int SessionId [get]
 Gets the Terminal Services session identifier for the associated process. More...
 
ProcessStartInfo StartInfo [get, set]
 Gets or sets the properties to pass to the M:System.Diagnostics.Process.Start method of the T:System.Diagnostics.Process. More...
 
DateTime StartTime [get]
 Gets the time that the associated process was started. More...
 
ISynchronizeInvoke SynchronizingObject [get, set]
 Gets or sets the object used to marshal the event handler calls that are issued as a result of a process exit event. More...
 
ProcessThreadCollection Threads [get]
 Gets the set of threads that are running in the associated process. More...
 
TimeSpan TotalProcessorTime [get]
 Gets the total processor time for this process. More...
 
TimeSpan UserProcessorTime [get]
 Gets the user processor time for this process. More...
 
int VirtualMemorySize [get]
 Gets the size of the process's virtual memory, in bytes. More...
 
long VirtualMemorySize64 [get]
 Gets the amount of the virtual memory, in bytes, allocated for the associated process. More...
 
bool EnableRaisingEvents [get, set]
 Gets or sets whether the E:System.Diagnostics.Process.Exited event should be raised when the process terminates. More...
 
StreamWriter StandardInput [get]
 Gets a stream used to write the input of the application. More...
 
StreamReader StandardOutput [get]
 Gets a stream used to read the textual output of the application. More...
 
StreamReader StandardError [get]
 Gets a stream used to read the error output of the application. More...
 
int WorkingSet [get]
 Gets the associated process's physical memory usage, in bytes. More...
 
long WorkingSet64 [get]
 Gets the amount of physical memory, in bytes, allocated for the associated process. More...
 
EventHandler Exited
 Occurs when a process exits. More...
 
- Properties inherited from System.ComponentModel.Component
EventHandlerList Events [get]
 Gets the list of event handlers that are attached to this T:System.ComponentModel.Component. More...
 
virtual ISite Site [get, set]
 Gets or sets the T:System.ComponentModel.ISite of the T:System.ComponentModel.Component. More...
 
IContainerContainer [get]
 Gets the T:System.ComponentModel.IContainer that contains the T:System.ComponentModel.Component. More...
 
bool??? DesignMode [get]
 Gets a value that indicates whether the T:System.ComponentModel.Component is currently in design mode. More...
 
EventHandler Disposed
 Occurs when the component is disposed by a call to the M:System.ComponentModel.Component.Dispose method. More...
 
- Properties inherited from System.ComponentModel.IComponent
ISite Site [get, set]
 Gets or sets the T:System.ComponentModel.ISite associated with the T:System.ComponentModel.IComponent. More...
 

Events

DataReceivedEventHandler OutputDataReceived
 Occurs each time an application writes a line to its redirected P:System.Diagnostics.Process.StandardOutput stream. More...
 
DataReceivedEventHandler ErrorDataReceived
 Occurs when an application writes to its redirected P:System.Diagnostics.Process.StandardError stream. More...
 
- Events inherited from System.ComponentModel.IComponent
EventHandler Disposed
 Represents the method that handles the E:System.ComponentModel.IComponent.Disposed event of a component. More...
 

Additional Inherited Members

- Protected Attributes inherited from System.ComponentModel.Component
virtual bool CanRaiseEvents => true
 Gets a value indicating whether the component can raise an event. More...
 

Detailed Description

Provides access to local and remote processes and enables you to start and stop local system processes.To browse the .NET Framework source code for this type, see the Reference Source.

Definition at line 25 of file Process.cs.

Constructor & Destructor Documentation

◆ Process()

System.Diagnostics.Process.Process ( )

Initializes a new instance of the T:System.Diagnostics.Process class.

Definition at line 1319 of file Process.cs.

Member Function Documentation

◆ BeginErrorReadLine()

void System.Diagnostics.Process.BeginErrorReadLine ( )

Begins asynchronous read operations on the redirected P:System.Diagnostics.Process.StandardError stream of the application.

Exceptions
T:System.InvalidOperationExceptionThe P:System.Diagnostics.ProcessStartInfo.RedirectStandardError property is false.- or - An asynchronous read operation is already in progress on the P:System.Diagnostics.Process.StandardError stream.- or - The P:System.Diagnostics.Process.StandardError stream has been used by a synchronous read operation.

Definition at line 2626 of file Process.cs.

◆ BeginOutputReadLine()

void System.Diagnostics.Process.BeginOutputReadLine ( )

Begins asynchronous read operations on the redirected P:System.Diagnostics.Process.StandardOutput stream of the application.

Exceptions
T:System.InvalidOperationExceptionThe P:System.Diagnostics.ProcessStartInfo.RedirectStandardOutput property is false.- or - An asynchronous read operation is already in progress on the P:System.Diagnostics.Process.StandardOutput stream.- or - The P:System.Diagnostics.Process.StandardOutput stream has been used by a synchronous read operation.

Definition at line 2596 of file Process.cs.

◆ CancelErrorRead()

void System.Diagnostics.Process.CancelErrorRead ( )

Cancels the asynchronous read operation on the redirected P:System.Diagnostics.Process.StandardError stream of an application.

Exceptions
T:System.InvalidOperationExceptionThe P:System.Diagnostics.Process.StandardError stream is not enabled for asynchronous read operations.

Definition at line 2670 of file Process.cs.

◆ CancelOutputRead()

void System.Diagnostics.Process.CancelOutputRead ( )

Cancels the asynchronous read operation on the redirected P:System.Diagnostics.Process.StandardOutput stream of an application.

Exceptions
T:System.InvalidOperationExceptionThe P:System.Diagnostics.Process.StandardOutput stream is not enabled for asynchronous read operations.

Definition at line 2656 of file Process.cs.

◆ Close()

void System.Diagnostics.Process.Close ( )

Frees all the resources that are associated with this component.

Definition at line 1419 of file Process.cs.

◆ CloseMainWindow()

bool System.Diagnostics.Process.CloseMainWindow ( )

Closes a process that has a user interface by sending a close message to its main window.

Returns
true if the close message was successfully sent; false if the associated process does not have a main window or if the main window is disabled (for example if a modal dialog is being shown).
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me); set the P:System.Diagnostics.ProcessStartInfo.UseShellExecute property to false to access this property on Windows 98 and Windows Me.
T:System.InvalidOperationExceptionThe process has already exited. -or-No process is associated with this T:System.Diagnostics.Process object.

Definition at line 1372 of file Process.cs.

◆ Dispose()

override void System.Diagnostics.Process.Dispose ( bool  disposing)
protectedvirtual

Release all resources used by this process.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

Reimplemented from System.ComponentModel.Component.

Definition at line 1405 of file Process.cs.

◆ EnterDebugMode()

static void System.Diagnostics.Process.EnterDebugMode ( )
static

Puts a T:System.Diagnostics.Process component in state to interact with operating system processes that run in a special mode by enabling the native property SeDebugPrivilege on the current thread.

Definition at line 1552 of file Process.cs.

◆ GetCurrentProcess()

static Process System.Diagnostics.Process.GetCurrentProcess ( )
static

Gets a new T:System.Diagnostics.Process component and associates it with the currently active process.

Returns
A new T:System.Diagnostics.Process component associated with the process resource that is running the calling application.

Definition at line 1697 of file Process.cs.

◆ GetProcessById() [1/2]

static Process System.Diagnostics.Process.GetProcessById ( int  processId,
string  machineName 
)
static

Returns a new T:System.Diagnostics.Process component, given a process identifier and the name of a computer on the network.

Parameters
processIdThe system-unique identifier of a process resource.
machineNameThe name of a computer on the network.
Returns
A T:System.Diagnostics.Process component that is associated with a remote process resource identified by the processId parameter.
Exceptions
T:System.ArgumentExceptionThe process specified by the processId parameter is not running. The identifier might be expired.-or- The machineName parameter syntax is invalid. The name might have length zero (0).
T:System.ArgumentNullExceptionThe machineName parameter is null.
T:System.InvalidOperationExceptionThe process was not started by this object.

Definition at line 1606 of file Process.cs.

◆ GetProcessById() [2/2]

static Process System.Diagnostics.Process.GetProcessById ( int  processId)
static

Returns a new T:System.Diagnostics.Process component, given the identifier of a process on the local computer.

Parameters
processIdThe system-unique identifier of a process resource.
Returns
A T:System.Diagnostics.Process component that is associated with the local process resource identified by the processId parameter.
Exceptions
T:System.ArgumentExceptionThe process specified by the processId parameter is not running. The identifier might be expired.
T:System.InvalidOperationExceptionThe process was not started by this object.

Definition at line 1620 of file Process.cs.

◆ GetProcesses() [1/2]

static Process [] System.Diagnostics.Process.GetProcesses ( )
static

Creates a new T:System.Diagnostics.Process component for each process resource on the local computer.

Returns
An array of type T:System.Diagnostics.Process that represents all the process resources running on the local computer.

Definition at line 1669 of file Process.cs.

◆ GetProcesses() [2/2]

static Process [] System.Diagnostics.Process.GetProcesses ( string  machineName)
static

Creates a new T:System.Diagnostics.Process component for each process resource on the specified computer.

Parameters
machineNameThe computer from which to read the list of processes.
Returns
An array of type T:System.Diagnostics.Process that represents all the process resources running on the specified computer.
Exceptions
T:System.ArgumentExceptionThe machineName parameter syntax is invalid. It might have length zero (0).
T:System.ArgumentNullExceptionThe machineName parameter is null.
T:System.PlatformNotSupportedExceptionThe operating system platform does not support this operation on remote computers.
T:System.InvalidOperationExceptionThere are problems accessing the performance counter API's used to get process information. This exception is specific to Windows NT, Windows 2000, and Windows XP.
T:System.ComponentModel.Win32ExceptionA problem occurred accessing an underlying system API.

Definition at line 1682 of file Process.cs.

◆ GetProcessesByName() [1/2]

static Process [] System.Diagnostics.Process.GetProcessesByName ( string  processName)
static

Creates an array of new T:System.Diagnostics.Process components and associates them with all the process resources on the local computer that share the specified process name.

Parameters
processNameThe friendly name of the process.
Returns
An array of type T:System.Diagnostics.Process that represents the process resources running the specified application or file.
Exceptions
T:System.InvalidOperationExceptionThere are problems accessing the performance counter API's used to get process information. This exception is specific to Windows NT, Windows 2000, and Windows XP.

Definition at line 1629 of file Process.cs.

◆ GetProcessesByName() [2/2]

static Process [] System.Diagnostics.Process.GetProcessesByName ( string  processName,
string  machineName 
)
static

Creates an array of new T:System.Diagnostics.Process components and associates them with all the process resources on a remote computer that share the specified process name.

Parameters
processNameThe friendly name of the process.
machineNameThe name of a computer on the network.
Returns
An array of type T:System.Diagnostics.Process that represents the process resources running the specified application or file.
Exceptions
T:System.ArgumentExceptionThe machineName parameter syntax is invalid. It might have length zero (0).
T:System.ArgumentNullExceptionThe machineName parameter is null.
T:System.PlatformNotSupportedExceptionThe operating system platform does not support this operation on remote computers.
T:System.InvalidOperationExceptionThere are problems accessing the performance counter API's used to get process information. This exception is specific to Windows NT, Windows 2000, and Windows XP.
T:System.ComponentModel.Win32ExceptionA problem occurred accessing an underlying system API.

Definition at line 1643 of file Process.cs.

◆ Kill()

void System.Diagnostics.Process.Kill ( )

Immediately stops the associated process.

Exceptions
T:System.ComponentModel.Win32ExceptionThe associated process could not be terminated. -or-The process is terminating.-or- The associated process is a Win16 executable.
T:System.NotSupportedExceptionYou are attempting to call M:System.Diagnostics.Process.Kill for a process that is running on a remote computer. The method is available only for processes running on the local computer.
T:System.InvalidOperationExceptionThe process has already exited. -or-There is no process associated with this T:System.Diagnostics.Process object.

Definition at line 2432 of file Process.cs.

◆ LeaveDebugMode()

static void System.Diagnostics.Process.LeaveDebugMode ( )
static

Takes a T:System.Diagnostics.Process component out of the state that lets it interact with operating system processes that run in a special mode.

Definition at line 1591 of file Process.cs.

◆ OnExited()

void System.Diagnostics.Process.OnExited ( )
protected

Raises the E:System.Diagnostics.Process.Exited event.

Definition at line 1703 of file Process.cs.

◆ Refresh()

void System.Diagnostics.Process.Refresh ( )

Discards any information about the associated process that has been cached inside the process component.

Definition at line 1798 of file Process.cs.

◆ Start() [1/6]

bool System.Diagnostics.Process.Start ( )

Starts (or reuses) the process resource that is specified by the P:System.Diagnostics.Process.StartInfo property of this T:System.Diagnostics.Process component and associates it with the component.

Returns
true if a process resource is started; false if no new process resource is started (for example, if an existing process is reused).
Exceptions
T:System.InvalidOperationExceptionNo file name was specified in the T:System.Diagnostics.Process component's P:System.Diagnostics.Process.StartInfo.-or- The P:System.Diagnostics.ProcessStartInfo.UseShellExecute member of the P:System.Diagnostics.Process.StartInfo property is true while P:System.Diagnostics.ProcessStartInfo.RedirectStandardInput, P:System.Diagnostics.ProcessStartInfo.RedirectStandardOutput, or P:System.Diagnostics.ProcessStartInfo.RedirectStandardError is true.
T:System.ComponentModel.Win32ExceptionThere was an error in opening the associated file.
T:System.ObjectDisposedExceptionThe process object has already been disposed.

Definition at line 1882 of file Process.cs.

◆ Start() [2/6]

static Process System.Diagnostics.Process.Start ( string  fileName,
string  userName,
SecureString  password,
string  domain 
)
static

Starts a process resource by specifying the name of an application, a user name, a password, and a domain and associates the resource with a new T:System.Diagnostics.Process component.

Parameters
fileNameThe name of an application file to run in the process.
userNameThe user name to use when starting the process.
passwordA T:System.Security.SecureString that contains the password to use when starting the process.
domainThe domain to use when starting the process.
Returns
A new T:System.Diagnostics.Process that is associated with the process resource, or null if no process resource is started. Note that a new process that’s started alongside already running instances of the same process will be independent from the others. In addition, Start may return a non-null Process with its P:System.Diagnostics.Process.HasExited property already set to true. In this case, the started process may have activated an existing instance of itself and then exited.
Exceptions
T:System.InvalidOperationExceptionNo file name was specified.
T:System.ComponentModel.Win32ExceptionfileName is not an executable (.exe) file.
T:System.ComponentModel.Win32ExceptionThere was an error in opening the associated file.
T:System.ObjectDisposedExceptionThe process object has already been disposed.

Definition at line 2349 of file Process.cs.

◆ Start() [3/6]

static Process System.Diagnostics.Process.Start ( string  fileName,
string  arguments,
string  userName,
SecureString  password,
string  domain 
)
static

Starts a process resource by specifying the name of an application, a set of command-line arguments, a user name, a password, and a domain and associates the resource with a new T:System.Diagnostics.Process component.

Parameters
fileNameThe name of an application file to run in the process.
argumentsCommand-line arguments to pass when starting the process.
userNameThe user name to use when starting the process.
passwordA T:System.Security.SecureString that contains the password to use when starting the process.
domainThe domain to use when starting the process.
Returns
A new T:System.Diagnostics.Process that is associated with the process resource, or null if no process resource is started. Note that a new process that’s started alongside already running instances of the same process will be independent from the others. In addition, Start may return a non-null Process with its P:System.Diagnostics.Process.HasExited property already set to true. In this case, the started process may have activated an existing instance of itself and then exited.
Exceptions
T:System.InvalidOperationExceptionNo file name was specified.
T:System.ComponentModel.Win32ExceptionfileName is not an executable (.exe) file.
T:System.ComponentModel.Win32ExceptionAn error occurred when opening the associated file. -or-The sum of the length of the arguments and the length of the full path to the associated file exceeds 2080. The error message associated with this exception can be one of the following: "The data area passed to a system call is too small." or "Access is denied."
T:System.ObjectDisposedExceptionThe process object has already been disposed.

Definition at line 2371 of file Process.cs.

◆ Start() [4/6]

static Process System.Diagnostics.Process.Start ( string  fileName)
static

Starts a process resource by specifying the name of a document or application file and associates the resource with a new T:System.Diagnostics.Process component.

Parameters
fileNameThe name of a document or application file to run in the process.
Returns
A new T:System.Diagnostics.Process that is associated with the process resource, or null if no process resource is started. Note that a new process that’s started alongside already running instances of the same process will be independent from the others. In addition, Start may return a non-null Process with its P:System.Diagnostics.Process.HasExited property already set to true. In this case, the started process may have activated an existing instance of itself and then exited.
Exceptions
T:System.ComponentModel.Win32ExceptionAn error occurred when opening the associated file.
T:System.ObjectDisposedExceptionThe process object has already been disposed.
T:System.IO.FileNotFoundExceptionThe PATH environment variable has a string containing quotes.

Definition at line 2387 of file Process.cs.

◆ Start() [5/6]

static Process System.Diagnostics.Process.Start ( string  fileName,
string  arguments 
)
static

Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new T:System.Diagnostics.Process component.

Parameters
fileNameThe name of an application file to run in the process.
argumentsCommand-line arguments to pass when starting the process.
Returns
A new T:System.Diagnostics.Process that is associated with the process resource, or null if no process resource is started. Note that a new process that’s started alongside already running instances of the same process will be independent from the others. In addition, Start may return a non-null Process with its P:System.Diagnostics.Process.HasExited property already set to true. In this case, the started process may have activated an existing instance of itself and then exited.
Exceptions
T:System.InvalidOperationExceptionThe fileName or arguments parameter is null.
T:System.ComponentModel.Win32ExceptionAn error occurred when opening the associated file. -or-The sum of the length of the arguments and the length of the full path to the process exceeds 2080. The error message associated with this exception can be one of the following: "The data area passed to a system call is too small." or "Access is denied."
T:System.ObjectDisposedExceptionThe process object has already been disposed.
T:System.IO.FileNotFoundExceptionThe PATH environment variable has a string containing quotes.

Definition at line 2400 of file Process.cs.

◆ Start() [6/6]

static Process System.Diagnostics.Process.Start ( ProcessStartInfo  startInfo)
static

Starts the process resource that is specified by the parameter containing process start information (for example, the file name of the process to start) and associates the resource with a new T:System.Diagnostics.Process component.

Parameters
startInfoThe T:System.Diagnostics.ProcessStartInfo that contains the information that is used to start the process, including the file name and any command-line arguments.
Returns
A new T:System.Diagnostics.Process that is associated with the process resource, or null if no process resource is started. Note that a new process that’s started alongside already running instances of the same process will be independent from the others. In addition, Start may return a non-null Process with its P:System.Diagnostics.Process.HasExited property already set to true. In this case, the started process may have activated an existing instance of itself and then exited.
Exceptions
T:System.InvalidOperationExceptionNo file name was specified in the startInfo parameter's P:System.Diagnostics.ProcessStartInfo.FileName property.-or- The P:System.Diagnostics.ProcessStartInfo.UseShellExecute property of the startInfo parameter is true and the P:System.Diagnostics.ProcessStartInfo.RedirectStandardInput, P:System.Diagnostics.ProcessStartInfo.RedirectStandardOutput, or P:System.Diagnostics.ProcessStartInfo.RedirectStandardError property is also true.-or-The P:System.Diagnostics.ProcessStartInfo.UseShellExecute property of the startInfo parameter is true and the P:System.Diagnostics.ProcessStartInfo.UserName property is not null or empty or the P:System.Diagnostics.ProcessStartInfo.Password property is not null.
T:System.ArgumentNullExceptionThe startInfo parameter is null.
T:System.ObjectDisposedExceptionThe process object has already been disposed.
T:System.IO.FileNotFoundExceptionThe file specified in the startInfo parameter's P:System.Diagnostics.ProcessStartInfo.FileName property could not be found.
T:System.ComponentModel.Win32ExceptionAn error occurred when opening the associated file. -or-The sum of the length of the arguments and the length of the full path to the process exceeds 2080. The error message associated with this exception can be one of the following: "The data area passed to a system call is too small." or "Access is denied."

Definition at line 2413 of file Process.cs.

◆ ToString()

override string System.Diagnostics.Process.ToString ( )

Formats the process's name as a string, combined with the parent component type, if applicable.

Returns
The P:System.Diagnostics.Process.ProcessName, combined with the base component's M:System.Object.ToString return value.
Exceptions
T:System.PlatformNotSupportedExceptionM:System.Diagnostics.Process.ToString is not supported on Windows 98.

Definition at line 2471 of file Process.cs.

◆ WaitForExit() [1/2]

bool System.Diagnostics.Process.WaitForExit ( int  milliseconds)

Instructs the T:System.Diagnostics.Process component to wait the specified number of milliseconds for the associated process to exit.

Parameters
millisecondsThe amount of time, in milliseconds, to wait for the associated process to exit. The maximum is the largest possible value of a 32-bit integer, which represents infinity to the operating system.
Returns
true if the associated process has exited; otherwise, false.
Exceptions
T:System.ComponentModel.Win32ExceptionThe wait setting could not be accessed.
T:System.SystemExceptionNo process P:System.Diagnostics.Process.Id has been set, and a P:System.Diagnostics.Process.Handle from which the P:System.Diagnostics.Process.Id property can be determined does not exist.-or- There is no process associated with this T:System.Diagnostics.Process object.-or- You are attempting to call M:System.Diagnostics.Process.WaitForExit(System.Int32) for a process that is running on a remote computer. This method is available only for processes that are running on the local computer.

Definition at line 2502 of file Process.cs.

◆ WaitForExit() [2/2]

void System.Diagnostics.Process.WaitForExit ( )

Instructs the T:System.Diagnostics.Process component to wait indefinitely for the associated process to exit.

Exceptions
T:System.ComponentModel.Win32ExceptionThe wait setting could not be accessed.
T:System.SystemExceptionNo process P:System.Diagnostics.Process.Id has been set, and a P:System.Diagnostics.Process.Handle from which the P:System.Diagnostics.Process.Id property can be determined does not exist.-or- There is no process associated with this T:System.Diagnostics.Process object.-or- You are attempting to call M:System.Diagnostics.Process.WaitForExit for a process that is running on a remote computer. This method is available only for processes that are running on the local computer.

Definition at line 2552 of file Process.cs.

◆ WaitForInputIdle() [1/2]

bool System.Diagnostics.Process.WaitForInputIdle ( int  milliseconds)

Causes the T:System.Diagnostics.Process component to wait the specified number of milliseconds for the associated process to enter an idle state. This overload applies only to processes with a user interface and, therefore, a message loop.

Parameters
millisecondsA value of 1 to F:System.Int32.MaxValue that specifies the amount of time, in milliseconds, to wait for the associated process to become idle. A value of 0 specifies an immediate return, and a value of -1 specifies an infinite wait.
Returns
true if the associated process has reached an idle state; otherwise, false.
Exceptions
T:System.InvalidOperationExceptionThe process does not have a graphical interface.-or-An unknown error occurred. The process failed to enter an idle state.-or-The process has already exited. -or-No process is associated with this T:System.Diagnostics.Process object.

Definition at line 2562 of file Process.cs.

◆ WaitForInputIdle() [2/2]

bool System.Diagnostics.Process.WaitForInputIdle ( )

Causes the T:System.Diagnostics.Process component to wait indefinitely for the associated process to enter an idle state. This overload applies only to processes with a user interface and, therefore, a message loop.

Returns
true if the associated process has reached an idle state.
Exceptions
T:System.InvalidOperationExceptionThe process does not have a graphical interface.-or-An unknown error occurred. The process failed to enter an idle state.-or-The process has already exited. -or-No process is associated with this T:System.Diagnostics.Process object.

Definition at line 2588 of file Process.cs.

Property Documentation

◆ BasePriority

int System.Diagnostics.Process.BasePriority
get

Gets the base priority of the associated process.

Returns
The base priority, which is computed from the P:System.Diagnostics.Process.PriorityClass of the associated process.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me); set the P:System.Diagnostics.ProcessStartInfo.UseShellExecute property to false to access this property on Windows 98 and Windows Me.
T:System.InvalidOperationExceptionThe process has exited.-or- The process has not started, so there is no process ID.

Definition at line 170 of file Process.cs.

◆ EnableRaisingEvents

bool System.Diagnostics.Process.EnableRaisingEvents
getset

Gets or sets whether the E:System.Diagnostics.Process.Exited event should be raised when the process terminates.

Returns
true if the E:System.Diagnostics.Process.Exited event should be raised when the associated process is terminated (through either an exit or a call to M:System.Diagnostics.Process.Kill); otherwise, false. The default is false.

Definition at line 1166 of file Process.cs.

◆ ExitCode

int System.Diagnostics.Process.ExitCode
get

Gets the value that the associated process specified when it terminated.

Returns
The code that the associated process specified when it terminated.
Exceptions
T:System.InvalidOperationExceptionThe process has not exited.-or- The process P:System.Diagnostics.Process.Handle is not valid.
T:System.NotSupportedExceptionYou are trying to access the P:System.Diagnostics.Process.ExitCode property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.

Definition at line 186 of file Process.cs.

◆ Exited

EventHandler System.Diagnostics.Process.Exited
addremove

Occurs when a process exits.

Definition at line 1307 of file Process.cs.

◆ ExitTime

DateTime System.Diagnostics.Process.ExitTime
get

Gets the time that the associated process exited.

Returns
A T:System.DateTime that indicates when the associated process was terminated.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.
T:System.NotSupportedExceptionYou are trying to access the P:System.Diagnostics.Process.ExitTime property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.

Definition at line 271 of file Process.cs.

◆ Handle

IntPtr System.Diagnostics.Process.Handle
get

Gets the native handle of the associated process.

Returns
The handle that the operating system assigned to the associated process when the process was started. The system uses this handle to keep track of process attributes.
Exceptions
T:System.InvalidOperationExceptionThe process has not been started or has exited. The P:System.Diagnostics.Process.Handle property cannot be read because there is no process associated with this T:System.Diagnostics.Process instance.-or- The T:System.Diagnostics.Process instance has been attached to a running process but you do not have the necessary permissions to get a handle with full access rights.
T:System.NotSupportedExceptionYou are trying to access the P:System.Diagnostics.Process.Handle property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.

Definition at line 292 of file Process.cs.

◆ HandleCount

int System.Diagnostics.Process.HandleCount
get

Gets the number of handles opened by the process.

Returns
The number of operating system handles the process has opened.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me); set the P:System.Diagnostics.ProcessStartInfo.UseShellExecute property to false to access this property on Windows 98 and Windows Me.

Definition at line 319 of file Process.cs.

◆ HasExited

bool? System.Diagnostics.Process.HasExited
get

Gets a value indicating whether the associated process has been terminated.

Returns
true if the operating system process referenced by the T:System.Diagnostics.Process component has terminated; otherwise, false.
Exceptions
T:System.InvalidOperationExceptionThere is no process associated with the object.
T:System.ComponentModel.Win32ExceptionThe exit code for the process could not be retrieved.
T:System.NotSupportedExceptionYou are trying to access the P:System.Diagnostics.Process.HasExited property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.

Definition at line 204 of file Process.cs.

◆ Id

int System.Diagnostics.Process.Id
get

Gets the unique identifier for the associated process.

Returns
The system-generated unique identifier of the process that is referenced by this T:System.Diagnostics.Process instance.
Exceptions
T:System.InvalidOperationExceptionThe process's P:System.Diagnostics.Process.Id property has not been set.-or- There is no process associated with this T:System.Diagnostics.Process object.
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me); set the P:System.Diagnostics.ProcessStartInfo.UseShellExecute property to false to access this property on Windows 98 and Windows Me.

Definition at line 334 of file Process.cs.

◆ MachineName

string System.Diagnostics.Process.MachineName
get

Gets the name of the computer the associated process is running on.

Returns
The name of the computer that the associated process is running on.
Exceptions
T:System.InvalidOperationExceptionThere is no process associated with this T:System.Diagnostics.Process object.

Definition at line 349 of file Process.cs.

◆ MainModule

ProcessModule System.Diagnostics.Process.MainModule
get

Gets the main module for the associated process.

Returns
The T:System.Diagnostics.ProcessModule that was used to start the process.
Exceptions
T:System.NotSupportedExceptionYou are trying to access the P:System.Diagnostics.Process.MainModule property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.
T:System.ComponentModel.Win32ExceptionA 32-bit process is trying to access the modules of a 64-bit process.
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me); set P:System.Diagnostics.ProcessStartInfo.UseShellExecute to false to access this property on Windows 98 and Windows Me.
T:System.InvalidOperationExceptionThe process P:System.Diagnostics.Process.Id is not available.-or- The process has exited.

Definition at line 425 of file Process.cs.

◆ MainWindowHandle

IntPtr System.Diagnostics.Process.MainWindowHandle
get

Gets the window handle of the main window of the associated process.

Returns
The system-generated window handle of the main window of the associated process.
Exceptions
T:System.InvalidOperationExceptionThe P:System.Diagnostics.Process.MainWindowHandle is not defined because the process has exited.
T:System.NotSupportedExceptionYou are trying to access the P:System.Diagnostics.Process.MainWindowHandle property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me); set P:System.Diagnostics.ProcessStartInfo.UseShellExecute to false to access this property on Windows 98 and Windows Me.

Definition at line 365 of file Process.cs.

◆ MainWindowTitle

string System.Diagnostics.Process.MainWindowTitle
get

Gets the caption of the main window of the process.

Returns
The main window title of the process.
Exceptions
T:System.InvalidOperationExceptionThe P:System.Diagnostics.Process.MainWindowTitle property is not defined because the process has exited.
T:System.NotSupportedExceptionYou are trying to access the P:System.Diagnostics.Process.MainWindowTitle property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me); set P:System.Diagnostics.ProcessStartInfo.UseShellExecute to false to access this property on Windows 98 and Windows Me.

Definition at line 393 of file Process.cs.

◆ MaxWorkingSet

IntPtr System.Diagnostics.Process.MaxWorkingSet
getset

Gets or sets the maximum allowable working set size, in bytes, for the associated process.

Returns
The maximum working set size that is allowed in memory for the process, in bytes.
Exceptions
T:System.ArgumentExceptionThe maximum working set size is invalid. It must be greater than or equal to the minimum working set size.
T:System.ComponentModel.Win32ExceptionWorking set information cannot be retrieved from the associated process resource.-or- The process identifier or process handle is zero because the process has not been started.
T:System.NotSupportedExceptionYou are trying to access the P:System.Diagnostics.Process.MaxWorkingSet property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.
T:System.InvalidOperationExceptionThe process P:System.Diagnostics.Process.Id is not available.-or- The process has exited.
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 457 of file Process.cs.

◆ MinWorkingSet

IntPtr System.Diagnostics.Process.MinWorkingSet
getset

Gets or sets the minimum allowable working set size, in bytes, for the associated process.

Returns
The minimum working set size that is required in memory for the process, in bytes.
Exceptions
T:System.ArgumentExceptionThe minimum working set size is invalid. It must be less than or equal to the maximum working set size.
T:System.ComponentModel.Win32ExceptionWorking set information cannot be retrieved from the associated process resource.-or- The process identifier or process handle is zero because the process has not been started.
T:System.NotSupportedExceptionYou are trying to access the P:System.Diagnostics.Process.MinWorkingSet property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.
T:System.InvalidOperationExceptionThe process P:System.Diagnostics.Process.Id is not available.-or- The process has exited.
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 479 of file Process.cs.

◆ Modules

ProcessModuleCollection System.Diagnostics.Process.Modules
get

Gets the modules that have been loaded by the associated process.

Returns
An array of type T:System.Diagnostics.ProcessModule that represents the modules that have been loaded by the associated process.
Exceptions
T:System.NotSupportedExceptionYou are attempting to access the P:System.Diagnostics.Process.Modules property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.
T:System.InvalidOperationExceptionThe process P:System.Diagnostics.Process.Id is not available.
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me); set P:System.Diagnostics.ProcessStartInfo.UseShellExecute to false to access this property on Windows 98 and Windows Me.
T:System.ComponentModel.Win32ExceptionYou are attempting to access the P:System.Diagnostics.Process.Modules property for either the system process or the idle process. These processes do not have modules.

Definition at line 501 of file Process.cs.

◆ NonpagedSystemMemorySize

int System.Diagnostics.Process.NonpagedSystemMemorySize
get

Gets the amount of nonpaged system memory, in bytes, allocated for the associated process.

Returns
The amount of memory, in bytes, the system has allocated for the associated process that cannot be written to the virtual memory paging file.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 526 of file Process.cs.

◆ NonpagedSystemMemorySize64

long System.Diagnostics.Process.NonpagedSystemMemorySize64
get

Gets the amount of nonpaged system memory, in bytes, allocated for the associated process.

Returns
The amount of system memory, in bytes, allocated for the associated process that cannot be written to the virtual memory paging file.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 541 of file Process.cs.

◆ PagedMemorySize

int System.Diagnostics.Process.PagedMemorySize
get

Gets the amount of paged memory, in bytes, allocated for the associated process.

Returns
The amount of memory, in bytes, allocated by the associated process that can be written to the virtual memory paging file.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 556 of file Process.cs.

◆ PagedMemorySize64

long System.Diagnostics.Process.PagedMemorySize64
get

Gets the amount of paged memory, in bytes, allocated for the associated process.

Returns
The amount of memory, in bytes, allocated in the virtual memory paging file for the associated process.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 571 of file Process.cs.

◆ PagedSystemMemorySize

int System.Diagnostics.Process.PagedSystemMemorySize
get

Gets the amount of pageable system memory, in bytes, allocated for the associated process.

Returns
The amount of memory, in bytes, the system has allocated for the associated process that can be written to the virtual memory paging file.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 586 of file Process.cs.

◆ PagedSystemMemorySize64

long System.Diagnostics.Process.PagedSystemMemorySize64
get

Gets the amount of pageable system memory, in bytes, allocated for the associated process.

Returns
The amount of system memory, in bytes, allocated for the associated process that can be written to the virtual memory paging file.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 601 of file Process.cs.

◆ PeakPagedMemorySize

int System.Diagnostics.Process.PeakPagedMemorySize
get

Gets the maximum amount of memory in the virtual memory paging file, in bytes, used by the associated process.

Returns
The maximum amount of memory, in bytes, allocated by the associated process that could be written to the virtual memory paging file.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 616 of file Process.cs.

◆ PeakPagedMemorySize64

long System.Diagnostics.Process.PeakPagedMemorySize64
get

Gets the maximum amount of memory in the virtual memory paging file, in bytes, used by the associated process.

Returns
The maximum amount of memory, in bytes, allocated in the virtual memory paging file for the associated process since it was started.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 631 of file Process.cs.

◆ PeakVirtualMemorySize

int System.Diagnostics.Process.PeakVirtualMemorySize
get

Gets the maximum amount of virtual memory, in bytes, used by the associated process.

Returns
The maximum amount of virtual memory, in bytes, that the associated process has requested.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 676 of file Process.cs.

◆ PeakVirtualMemorySize64

long System.Diagnostics.Process.PeakVirtualMemorySize64
get

Gets the maximum amount of virtual memory, in bytes, used by the associated process.

Returns
The maximum amount of virtual memory, in bytes, allocated for the associated process since it was started.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 691 of file Process.cs.

◆ PeakWorkingSet

int System.Diagnostics.Process.PeakWorkingSet
get

Gets the peak working set size for the associated process, in bytes.

Returns
The maximum amount of physical memory that the associated process has required all at once, in bytes.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 646 of file Process.cs.

◆ PeakWorkingSet64

long System.Diagnostics.Process.PeakWorkingSet64
get

Gets the maximum amount of physical memory, in bytes, used by the associated process.

Returns
The maximum amount of physical memory, in bytes, allocated for the associated process since it was started.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 661 of file Process.cs.

◆ PriorityBoostEnabled

bool System.Diagnostics.Process.PriorityBoostEnabled
getset

Gets or sets a value indicating whether the associated process priority should temporarily be boosted by the operating system when the main window has the focus.

Returns
true if dynamic boosting of the process priority should take place for a process when it is taken out of the wait state; otherwise, false. The default is false.
Exceptions
T:System.ComponentModel.Win32ExceptionPriority boost information could not be retrieved from the associated process resource.
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.-or- The process identifier or process handle is zero. (The process has not been started.)
T:System.NotSupportedExceptionYou are attempting to access the P:System.Diagnostics.Process.PriorityBoostEnabled property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.
T:System.InvalidOperationExceptionThe process P:System.Diagnostics.Process.Id is not available.

Definition at line 721 of file Process.cs.

◆ PriorityClass

ProcessPriorityClass System.Diagnostics.Process.PriorityClass
getset

Gets or sets the overall priority category for the associated process.

Returns
The priority category for the associated process, from which the P:System.Diagnostics.Process.BasePriority of the process is calculated.
Exceptions
T:System.ComponentModel.Win32ExceptionProcess priority information could not be set or retrieved from the associated process resource.-or- The process identifier or process handle is zero. (The process has not been started.)
T:System.NotSupportedExceptionYou are attempting to access the P:System.Diagnostics.Process.PriorityClass property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.
T:System.InvalidOperationExceptionThe process P:System.Diagnostics.Process.Id is not available.
T:System.PlatformNotSupportedExceptionYou have set the P:System.Diagnostics.Process.PriorityClass to AboveNormal or BelowNormal when using Windows 98 or Windows Millennium Edition (Windows Me). These platforms do not support those values for the priority class.
T:System.ComponentModel.InvalidEnumArgumentExceptionPriority class cannot be set because it does not use a valid value, as defined in the T:System.Diagnostics.ProcessPriorityClass enumeration.

Definition at line 777 of file Process.cs.

◆ PrivateMemorySize

int System.Diagnostics.Process.PrivateMemorySize
get

Gets the amount of private memory, in bytes, allocated for the associated process.

Returns
The number of bytes allocated by the associated process that cannot be shared with other processes.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 836 of file Process.cs.

◆ PrivateMemorySize64

long System.Diagnostics.Process.PrivateMemorySize64
get

Gets the amount of private memory, in bytes, allocated for the associated process.

Returns
The amount of memory, in bytes, allocated for the associated process that cannot be shared with other processes.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 851 of file Process.cs.

◆ PrivilegedProcessorTime

TimeSpan System.Diagnostics.Process.PrivilegedProcessorTime
get

Gets the privileged processor time for this process.

Returns
A T:System.TimeSpan that indicates the amount of time that the process has spent running code inside the operating system core.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.
T:System.NotSupportedExceptionYou are attempting to access the P:System.Diagnostics.Process.PrivilegedProcessorTime property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.

Definition at line 866 of file Process.cs.

◆ ProcessName

string System.Diagnostics.Process.ProcessName
get

Gets the name of the process.

Returns
The name that the system uses to identify the process to the user.
Exceptions
T:System.InvalidOperationExceptionThe process does not have an identifier, or no process is associated with the T:System.Diagnostics.Process.-or- The associated process has exited.
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me); set P:System.Diagnostics.ProcessStartInfo.UseShellExecute to false to access this property on Windows 98 and Windows Me.
T:System.NotSupportedExceptionThe process is not on this computer.

Definition at line 882 of file Process.cs.

◆ ProcessorAffinity

IntPtr System.Diagnostics.Process.ProcessorAffinity
getset

Gets or sets the processors on which the threads in this process can be scheduled to run.

Returns
A bitmask representing the processors that the threads in the associated process can run on. The default depends on the number of processors on the computer. The default value is 2 n -1, where n is the number of processors.
Exceptions
T:System.ComponentModel.Win32ExceptionP:System.Diagnostics.Process.ProcessorAffinity information could not be set or retrieved from the associated process resource.-or- The process identifier or process handle is zero. (The process has not been started.)
T:System.NotSupportedExceptionYou are attempting to access the P:System.Diagnostics.Process.ProcessorAffinity property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.
T:System.InvalidOperationExceptionThe process P:System.Diagnostics.Process.Id was not available.-or- The process has exited.

Definition at line 914 of file Process.cs.

◆ Responding

bool System.Diagnostics.Process.Responding
get

Gets a value indicating whether the user interface of the process is responding.

Returns
true if the user interface of the associated process is responding to the system; otherwise, false.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me); set P:System.Diagnostics.ProcessStartInfo.UseShellExecute to false to access this property on Windows 98 and Windows Me.
T:System.InvalidOperationExceptionThere is no process associated with this T:System.Diagnostics.Process object.
T:System.NotSupportedExceptionYou are attempting to access the P:System.Diagnostics.Process.Responding property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.

Definition at line 966 of file Process.cs.

◆ SafeHandle

SafeProcessHandle System.Diagnostics.Process.SafeHandle
get

Gets the native handle to this process.

Returns
The native handle to this process.

Definition at line 305 of file Process.cs.

◆ SessionId

int System.Diagnostics.Process.SessionId
get

Gets the Terminal Services session identifier for the associated process.

Returns
The Terminal Services session identifier for the associated process.
Exceptions
T:System.NullReferenceExceptionThere is no session associated with this process.
T:System.InvalidOperationExceptionThere is no process associated with this session identifier.-or-The associated process is not on this machine.
T:System.PlatformNotSupportedExceptionThe P:System.Diagnostics.Process.SessionId property is not supported on Windows 98.

Definition at line 993 of file Process.cs.

◆ StandardError

StreamReader System.Diagnostics.Process.StandardError
get

Gets a stream used to read the error output of the application.

Returns
A T:System.IO.StreamReader that can be used to read the standard error stream of the application.
Exceptions
T:System.InvalidOperationExceptionThe P:System.Diagnostics.Process.StandardError stream has not been defined for redirection; ensure P:System.Diagnostics.ProcessStartInfo.RedirectStandardError is set to true and P:System.Diagnostics.ProcessStartInfo.UseShellExecute is set to false.- or - The P:System.Diagnostics.Process.StandardError stream has been opened for asynchronous read operations with M:System.Diagnostics.Process.BeginErrorReadLine.

Definition at line 1244 of file Process.cs.

◆ StandardInput

StreamWriter System.Diagnostics.Process.StandardInput
get

Gets a stream used to write the input of the application.

Returns
A T:System.IO.StreamWriter that can be used to write the standard input stream of the application.
Exceptions
T:System.InvalidOperationExceptionThe P:System.Diagnostics.Process.StandardInput stream has not been defined because P:System.Diagnostics.ProcessStartInfo.RedirectStandardInput is set to false.

Definition at line 1200 of file Process.cs.

◆ StandardOutput

StreamReader System.Diagnostics.Process.StandardOutput
get

Gets a stream used to read the textual output of the application.

Returns
A T:System.IO.StreamReader that can be used to read the standard output stream of the application.
Exceptions
T:System.InvalidOperationExceptionThe P:System.Diagnostics.Process.StandardOutput stream has not been defined for redirection; ensure P:System.Diagnostics.ProcessStartInfo.RedirectStandardOutput is set to true and P:System.Diagnostics.ProcessStartInfo.UseShellExecute is set to false.- or - The P:System.Diagnostics.Process.StandardOutput stream has been opened for asynchronous read operations with M:System.Diagnostics.Process.BeginOutputReadLine.

Definition at line 1218 of file Process.cs.

◆ StartInfo

ProcessStartInfo System.Diagnostics.Process.StartInfo
getset

Gets or sets the properties to pass to the M:System.Diagnostics.Process.Start method of the T:System.Diagnostics.Process.

Returns
The T:System.Diagnostics.ProcessStartInfo that represents the data with which to start the process. These arguments include the name of the executable file or document used to start the process.
Exceptions
T:System.ArgumentNullExceptionThe value that specifies the P:System.Diagnostics.Process.StartInfo is null.

Definition at line 1008 of file Process.cs.

◆ StartTime

DateTime System.Diagnostics.Process.StartTime
get

Gets the time that the associated process was started.

Returns
An object that indicates when the process started. An exception is thrown if the process is not running.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.
T:System.NotSupportedExceptionYou are attempting to access the P:System.Diagnostics.Process.StartTime property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.
T:System.InvalidOperationExceptionThe process has exited.-or-The process has not been started.
T:System.ComponentModel.Win32ExceptionAn error occurred in the call to the Windows function.

Definition at line 1036 of file Process.cs.

◆ SynchronizingObject

ISynchronizeInvoke System.Diagnostics.Process.SynchronizingObject
getset

Gets or sets the object used to marshal the event handler calls that are issued as a result of a process exit event.

Returns
The T:System.ComponentModel.ISynchronizeInvoke used to marshal event handler calls that are issued as a result of an E:System.Diagnostics.Process.Exited event on the process.

Definition at line 1050 of file Process.cs.

◆ Threads

ProcessThreadCollection System.Diagnostics.Process.Threads
get

Gets the set of threads that are running in the associated process.

Returns
An array of type T:System.Diagnostics.ProcessThread representing the operating system threads currently running in the associated process.
Exceptions
T:System.SystemExceptionThe process does not have an P:System.Diagnostics.Process.Id, or no process is associated with the T:System.Diagnostics.Process instance.-or- The associated process has exited.
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me); set P:System.Diagnostics.ProcessStartInfo.UseShellExecute to false to access this property on Windows 98 and Windows Me.

Definition at line 1081 of file Process.cs.

◆ TotalProcessorTime

TimeSpan System.Diagnostics.Process.TotalProcessorTime
get

Gets the total processor time for this process.

Returns
A T:System.TimeSpan that indicates the amount of time that the associated process has spent utilizing the CPU. This value is the sum of the P:System.Diagnostics.Process.UserProcessorTime and the P:System.Diagnostics.Process.PrivilegedProcessorTime.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.
T:System.NotSupportedExceptionYou are attempting to access the P:System.Diagnostics.Process.TotalProcessorTime property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.

Definition at line 1106 of file Process.cs.

◆ UserProcessorTime

TimeSpan System.Diagnostics.Process.UserProcessorTime
get

Gets the user processor time for this process.

Returns
A T:System.TimeSpan that indicates the amount of time that the associated process has spent running code inside the application portion of the process (not inside the operating system core).
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.
T:System.NotSupportedExceptionYou are attempting to access the P:System.Diagnostics.Process.UserProcessorTime property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer.

Definition at line 1121 of file Process.cs.

◆ VirtualMemorySize

int System.Diagnostics.Process.VirtualMemorySize
get

Gets the size of the process's virtual memory, in bytes.

Returns
The amount of virtual memory, in bytes, that the associated process has requested.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 1136 of file Process.cs.

◆ VirtualMemorySize64

long System.Diagnostics.Process.VirtualMemorySize64
get

Gets the amount of the virtual memory, in bytes, allocated for the associated process.

Returns
The amount of virtual memory, in bytes, allocated for the associated process.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 1151 of file Process.cs.

◆ WorkingSet

int System.Diagnostics.Process.WorkingSet
get

Gets the associated process's physical memory usage, in bytes.

Returns
The total amount of physical memory the associated process is using, in bytes.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 1270 of file Process.cs.

◆ WorkingSet64

long System.Diagnostics.Process.WorkingSet64
get

Gets the amount of physical memory, in bytes, allocated for the associated process.

Returns
The amount of physical memory, in bytes, allocated for the associated process.
Exceptions
T:System.PlatformNotSupportedExceptionThe platform is Windows 98 or Windows Millennium Edition (Windows Me), which does not support this property.

Definition at line 1285 of file Process.cs.

Event Documentation

◆ ErrorDataReceived

DataReceivedEventHandler System.Diagnostics.Process.ErrorDataReceived

Occurs when an application writes to its redirected P:System.Diagnostics.Process.StandardError stream.

Definition at line 1301 of file Process.cs.

◆ OutputDataReceived

DataReceivedEventHandler System.Diagnostics.Process.OutputDataReceived

Occurs each time an application writes a line to its redirected P:System.Diagnostics.Process.StandardOutput stream.

Definition at line 1296 of file Process.cs.


The documentation for this class was generated from the following file: