非常感谢各位,问题解决! 在这里说一下解决的方法,希望以后朋友们再遇到这个问题可以解决!
解决办法:
给要关闭的进程设置一些属性,然后再执行process.kill(),下面是我程序的代码 贴出供大家参考!
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process myProcess in myProcesses)
{
if (myProcess.ProcessName.ToUpper() == "IEXPLORE")
{
try
{
myProcess.StartInfo.FileName = "iexplore.exe";
myProcess.StartInfo.Arguments = "";
myProcess.StartInfo.WorkingDirectory = "";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.StartInfo.ErrorDialog = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Kill();
}
catch(Exception ex)
{
txtlog.Write("关闭IE文件出错!"+ex.Message);
continue;
}
}
}
解决办法:
给要关闭的进程设置一些属性,然后再执行process.kill(),下面是我程序的代码 贴出供大家参考!
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process myProcess in myProcesses)
{
if (myProcess.ProcessName.ToUpper() == "IEXPLORE")
{
try
{
myProcess.StartInfo.FileName = "iexplore.exe";
myProcess.StartInfo.Arguments = "";
myProcess.StartInfo.WorkingDirectory = "";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.StartInfo.ErrorDialog = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Kill();
}
catch(Exception ex)
{
txtlog.Write("关闭IE文件出错!"+ex.Message);
continue;
}
}
}