Get all processes on local machine : Process « Development « C# / CSharp Tutorial






using System;
using System.Diagnostics;

class MainClass
{
  static void Main(string[] args)
  {
    Process[] runningProcs = Process.GetProcesses(".");
    foreach(Process p in runningProcs)
    {
      string info = string.Format("-> PID: {0}\tName: {1}",p.Id, p.ProcessName);        
      Console.WriteLine(info);
    }
  }
}
-> PID: 1636    Name: explorer
-> PID: 1064    Name: svchost
-> PID: 884     Name: svchost
-> PID: 972     Name: svchost
-> PID: 1592    Name: postgres
-> PID: 700     Name: services
-> PID: 1140    Name: svchost
-> PID: 2472    Name: firefox
-> PID: 2560    Name: wuauclt
-> PID: 156     Name: atiptaxx
-> PID: 2908    Name: main
-> PID: 772     Name: wuauclt
-> PID: 1572    Name: ati2evxx
-> PID: 856     Name: cmd
-> PID: 320     Name: cachemgr
-> PID: 2808    Name: uedit32
-> PID: 1472    Name: postgres
-> PID: 848     Name: ati2evxx
-> PID: 1556    Name: postgres
-> PID: 128     Name: SynTPEnh
-> PID: 292     Name: ctfmon
-> PID: 568     Name: smss
-> PID: 656     Name: winlogon
-> PID: 388     Name: ICMON
-> PID: 716     Name: pg_ctl
-> PID: 116     Name: SynTPLpr
-> PID: 1272    Name: svchost
-> PID: 1716    Name: spoolsv
-> PID: 712     Name: lsass
-> PID: 1264    Name: postgres
-> PID: 1348    Name: postmaster
-> PID: 2504    Name: wscntfy
-> PID: 1168    Name: alg
-> PID: 632     Name: csrss
-> PID: 1876    Name: SWNETSUP
-> PID: 2764    Name: SWEEPSRV.SYS
-> PID: 4       Name: System
-> PID: 536     Name: imonitor
-> PID: 624     Name: TNSLSNR
-> PID: 0       Name: Idle








14.15.Process
14.15.1.Starting Processes by using ProcessStartInfo
14.15.2.Starting a new process.
14.15.3.Detecting Process Completion
14.15.4.Redirecting Process Output
14.15.5.Get all processes on local machine
14.15.6.Enumerate over threads in a given PID
14.15.7.Enumerate over mods in a given PID
14.15.8.Launch / kill a process
14.15.9.Threads in Current Process
14.15.10.Property of current Process
14.15.11.Change priority for current process
14.15.12.List all process threads in current running processes
14.15.13.All current running processes
14.15.14.Listing processes on a remote machine
14.15.15.Get processes by name
14.15.16.Get all processes running on the local computer
14.15.17.Get all processes running on the remote computer
14.15.18.Get a process on the local computer, using the process id
14.15.19.Get a process on a remote computer, using the process id
14.15.20.Display the process statistics until the user closes the program
14.15.21.Uses the ProcessStartInfo class to start new processes, both in a minimized mode
14.15.22.Using an IP address to specify the machineName parameter
14.15.23.Start a Web page using a browser associated with .html and .asp files
14.15.24.Using the computer alias (do not precede with "\\")