This documentation is archived and is not being maintained.

Process.Id Property

Gets the unique identifier for the associated process.

[Visual Basic]
Public ReadOnly Property Id As Integer
public int Id {get;}
public: __property int get_Id();
public function get Id() : int;

Property Value

The system-generated unique identifier of the process that is referenced by this Process instance.


Exception Type Condition
InvalidOperationException The process's Id property has not been set.


There is no process associated with this Process object.


The process Id does not exist if the associated process is not running. Therefore, you should either ensure that the process is running before attempting to retrieve the Id property or handle the exception that will be thrown if the process has not been started. Until the process terminates, the process identifier uniquely identifies the process throughout the system.

You can connect a process that is running on a local or remote computer to a new Process instance by passing the process identifier to the GetProcessById method. GetProcessById is a static (Shared in Visual Basic) method that creates a new component and sets the Id property for the new Process instance automatically.

Process identifiers can be reused by the system. The Id property value is unique only while the associated process is running. After the process has terminated, the system can reuse the Id property value for an unrelated process.

Because the identifier is unique on the system, you can pass it to other threads as an alternative to passing a Process instance. This action can save system resources yet guarantee that the process is correctly identified.

Windows 98 Platform Note:  This property is not available on this platform if you started the process with ProcessStartInfo.UseShellExecute set to true.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

Process Class | Process Members | System.Diagnostics Namespace | Handle | GetProcessById