關閉IE進程出錯,提示拒絕訪問


解決辦法:
  對關閉的進程設置一些屬性,而後再執行process.kill()
 ide

代碼spa

 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
相關文章
相關標籤/搜索