public static void KillApp(string appName)
{
try
{
if (string.IsNullOrWhiteSpace(appName) || !appName.EndsWith(".exe")) return; //
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "taskkill.exe";
startInfo.Arguments = string.Format(" /f /t /im {0}", appName);
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Verb = @"runas";
Log.Debug(string.Format("[KillApp] run kill {0} start", appName));
Process process = Process.Start(startInfo);
process.WaitForExit();
Log.Debug(string.Format("[KillApp] run kill {0} end", appName));
}
catch (System.Exception ex)
{
Log.Error(string.Format("[KillApp] run kill {0} failed ", appName), ex);
}
}