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

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0