Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 bool LaunchOnBeforeInstall()
{
    var result = MessageBox.Show("All instance of IE will be close", "Warning", MessageBoxButtons.OKCancel,
    MessageBoxIcon.Question);
    return result != DialogResult.Cancel;
}
like image 993
czetsuya Avatar asked Nov 22 '25 07:11

czetsuya


1 Answers

Your problem:

if (!process.ProcessName.StartsWith("iexplore"))
{
process.Kill();
}

Your program is trying to kill everything EXCEPT for Internet Explorer

like image 115
Matt Avatar answered Nov 23 '25 20:11

Matt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!