关闭IE进程出错,提示拒绝访问


解决办法:
  对关闭的进程设置一些属性,然后再执行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             }
View Code

 

posted @ 2015-12-09 12:11  Maculish  阅读(278)  评论(0编辑  收藏  举报