Custom action check if IE is running then close it when it does
I'm trying to create a plugin installer for IE, so before the installation continue the IE process must be kill. But when I executed the kill()
method on the IE process I got "Access denied" error.
What would be the best approach for this?
My Installer code:
protected override void OnBeforeInstall(System.Collections.IDictionary savedState)
{
if (LaunchOnBeforeInstall())
{
foreach (var process in Process.GetProcesses())
{
if (!process.ProcessName.StartsWith("iexplore"))
{
process.Kill();
}
}
base.OnBeforeInstall(savedState);
}
else
{
throw new Exception("You cancelled the installation.");
}
}
public boo开发者_运维问答l LaunchOnBeforeInstall()
{
var result = MessageBox.Show("All instance of IE will be close", "Warning", MessageBoxButtons.OKCancel,
MessageBoxIcon.Question);
return result != DialogResult.Cancel;
}
Your problem:
if (!process.ProcessName.StartsWith("iexplore"))
{
process.Kill();
}
Your program is trying to kill everything EXCEPT for Internet Explorer
精彩评论