码迷,mamicode.com
首页 > 系统相关 > 详细

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

时间:2015-12-09 13:36:53      阅读:720      评论:0      收藏:0      [点我收藏+]

标签:


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

 

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

标签:

原文地址:http://www.cnblogs.com/Maculish/p/5032414.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!