Use one of the following code snippets:
using System.Diagnostics;
. . .
private static void KillProcessThread(string processName)
{
Process[] processes;
processes = Process.GetProcessesByName(processName);
foreach(Process proc in processes)
{
proc.Kill();
}
}
using System.ServiceProcess;
. . .
private static void KillWindowsService(string serviceName)
{
ServiceController sc = new ServiceController();
sc.ServiceName = serviceName;
sc.Stop();
}
No comments:
Post a Comment