I want to kill all the excel process which are running in the system before I start my application.How can I do that in C#?
Asked
Active
Viewed 435 times
2 Answers
4
This will work:
foreach (Process p in Process.GetProcessesByName("EXCEL"))
{
p.Kill();
}
-
I took out the .EXE as the process name is supposed to be a "friendly name" as defined by the MSDN, a name without file extension. – Archibald Aug 18 '16 at 20:15
2
using System.Diagnostics;
try
{
foreach (var p in Process.GetProcessesByName("EXCEL.EXE"))
p.Kill();
}

Mike
- 874
- 1
- 8
- 15