开发者

Custom action check if IE is running then close it when it does

开发者 https://www.devze.com 2023-03-04 15:32 出处:网络
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.

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

精彩评论

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

关注公众号