Launch / kill a process : Process « Development « C# / CSharp Tutorial






using System;
using System.Diagnostics;

class MainClass
{

  static void Main(string[] args)
  {
    Console.Write("--> Hit a key to launch IE");
    Console.ReadLine();

    // Launch IE.
    Process ieProc = Process.Start("IExplore.exe", "www.java2s.com");

    Console.Write("--> Hit a key to kill {0}...", ieProc.ProcessName);
    Console.ReadLine();

    try
    {
      ieProc.Kill();
    }
    catch{} // In case user already killed it...
  }
}
--> Hit a key to launch IE
--> Hit a key to kill IEXPLORE...








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 "\\")