Link to home
Start Free TrialLog in
Avatar of countrymeister
countrymeister

asked on

Killing a process from asp.net page

I have an ASP.NET page which invokes excel, and I intend to kill this excel process once the program has completed creating the reqd excel spreadsheet

I have the following code so far, when I try to kill the Excel process it states Access denied.
I am running the website under a given user account, which has administrative privileges.
My question is why can't I kill the process.


msBook.Close(false, msobjOpt, msobjOpt);

        msBooks.Close();

        msXL.Quit();        

        try

        {

            Marshal.ReleaseComObject(msXL);

            msXL = null;

            GC.Collect();

        }

        catch (Exception ex)

        {

        }

        //Kill older Excel processes

        try

        {

            Process[] p = Process.GetProcessesByName("EXCEL");

            ////kills all processes older than 15 minutes

            for (int i = 0; i < p.Length; i++)

                //if (p[i].StartTime.AddMinutes(2) < DateTime.Now)

                p[i].Kill;

        }

        catch (Exception ex)

        {

        }

ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial