开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜