Start Stop Process Programatically C# with Example



Start Stop Process Programatically C# with Example

 using System;
using System.Linq;
using System.Diagnostics;

namespace CSharpMultiThreading
{
    class MainMethodClass
    {
        static void Main()
        {
			StartAndKillProcess();
        }
    	
		static void StartAndKillProcess()
		{
			Process ieProc = null;
			// Launch Internet Explorer, and go to facebook!
			try
			{
				ieProc = Process.Start("IExplore.exe", "www.bccfalna.com");
			}
			catch (InvalidOperationException ex)
			{
				Console.WriteLine(ex.Message);
			}
	
			Console.Write("--> Hit enter to kill {0}...", ieProc.ProcessName);
			Console.ReadLine();
			
			// Kill the iexplore.exe process.
			try
			{
				ieProc.Kill();
			}
			catch (InvalidOperationException ex)
			{
				Console.WriteLine(ex.Message);
			}
		}
	}
}
 

0 Comment's

Comment Form