Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Process::MachineName Property

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

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

property String^ MachineName {
	String^ 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.dll>

using namespace System;
using namespace System::Diagnostics;
int main()
      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. 
      array<Process^>^myProcesses = Process::GetProcessesByName( "notepad", remoteMachineName );
      if ( myProcesses->Length == 0 )
            Console::WriteLine( "Could not find notepad processes on remote computer." );
      Collections::IEnumerator^ myEnum = myProcesses->GetEnumerator();
      while ( myEnum->MoveNext() )
         Process^ myProcess = safe_cast<Process^>(myEnum->Current);
         Console::Write( "Process Name : {0}  Process ID : {1}  MachineName : {2}\n", myProcess->ProcessName, myProcess->Id, myProcess->MachineName );
   catch ( SystemException^ e ) 
      Console::Write( "Caught Exception .... : {0}", e->Message );
   catch ( Exception^ e ) 
      Console::Write( "Caught Exception .... : {0}", e->Message );


.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

  • LinkDemand 

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

© 2015 Microsoft