标签:
解决办法:
对关闭的进程设置一些属性,然后再执行process.kill()
代码
1 System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses(); 2 3 foreach (System.Diagnostics.Process myProcess in myProcesses) 4 { 5 if (myProcess.ProcessName.ToUpper() == "IEXPLORE") 6 { 7 8 try 9 { 10 myProcess.StartInfo.FileName = "iexplore.exe"; 11 myProcess.StartInfo.Arguments = ""; 12 myProcess.StartInfo.WorkingDirectory = ""; 13 myProcess.StartInfo.UseShellExecute = false; 14 myProcess.StartInfo.RedirectStandardInput = true; 15 myProcess.StartInfo.RedirectStandardOutput = true; 16 myProcess.StartInfo.RedirectStandardError = true; 17 myProcess.StartInfo.ErrorDialog = false; 18 myProcess.StartInfo.CreateNoWindow = true; 19 myProcess.Kill(); 20 21 } 22 catch(Exception ex) 23 { 24 txtlog.Write("关闭IE文件出错!"+ex.Message); 25 26 continue; 27 } 28 } 29 }
标签:
原文地址:http://www.cnblogs.com/Maculish/p/5032414.html