日期:2014-05-17 浏览次数:20983 次
/// <summary>
/// 杀死应用程序
/// </summary>
/// <param name="appname"></param>
protected void KillMainApp(string mainAppExe)
{
Process[] allProcess = Process.GetProcesses();
foreach (Process p in allProcess)
{
if (p.ProcessName.ToLower() + ".exe" == mainAppExe.ToLower())
{
if (p.CloseMainWindow() == false)
{
p.Kill();
Thread.Sleep(1500);
LogHelper.WriteLog("kill"+ p.ProcessName);
}
else
{
p.WaitForExit(5000);
LogHelper.WriteLog("close" + p.ProcessName);
}