This documentation is archived and is not being maintained.

Process.MachineName Property

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

Namespace:  System.Diagnostics
Assembly:  System (in System.dll)

public string MachineName { get; }

Property Value

Type: System.String
The name of the computer that the associated process is running on.


There is no process associated with this Process object.

You can view statistical data and process information for processes running on remote computers but you cannot call Start, CloseMainWindow, or Kill on remote computers.


When the associated process is executing on the local machine, this property returns a period (".") for the machine name. You should use the Environment.MachineName property to get the correct machine name.

To use the following example you must first start at least one instance of Notepad on a remote computer. The example requests the name of the remote computer on which Notepad is running, and then displays the respective ProcessName, Id, and MachineName properties for each instance.

using System;
using System.Diagnostics;

class GetProcessesByNameClass
   public static void Main(string[] args)

         Console.Write("Create notepad processes on remote computer \n");
         Console.Write("Enter remote computer name : ");
         string remoteMachineName = Console.ReadLine();
         // Get all notepad processess into Process array.
         Process[] myProcesses = Process.GetProcessesByName("notepad",remoteMachineName);
         if(myProcesses.Length == 0)
            Console.WriteLine("Could not find notepad processes on remote computer.");
         foreach(Process myProcess in myProcesses)
            Console.Write("Process Name : " + myProcess.ProcessName + "  Process ID : "
               + myProcess.Id + "  MachineName : " + myProcess.MachineName + "\n");

      catch(SystemException e)
         Console.Write("Caught Exception .... : " + e.Message);
      catch(Exception e)
         Console.Write("Caught Exception .... : " + e.Message);

  • LinkDemand 

    for full trust for the immediate caller. This member cannot be used by partially trusted code.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0