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 */
public String get_MachineName ()

public function get MachineName () : String

Not applicable.

Property Value

The name of the computer that the associated process is running on.

Exception typeCondition


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 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions