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.

Exception Condition

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);


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

.NET Framework
Available since 1.1
Return to top