Kill specific Excel process

1. KillSpecificExcelFileProcess(“example1.xlsx”);

2. private void KillSpecificExcelFileProcess(string excelFileName){

var processes = from p in Process.GetProcessesByName(“EXCEL”)
select p;

foreach (var process in processes){

if (process.MainWindowTitle.Contains(“Microsoft Excel – ” + excelFileName))

process.Kill();

}

}

Kill a program

Process[] proc = Process.GetProcessByName(“mspaint”);

foreach(Process prs in proc){

prs.Kill();

}

OR

foreach(var process in Process.GetProcessByName(“paint”)){

process.Kill();

}