Solved

Cannot end process

Posted on 2007-11-20
3
1,125 Views
Last Modified: 2013-12-17
I am trying to kill a process programmatically. I check to see if it is running and then try to kill it and I get the following exception and the process is not killed

base {System.SystemException} = {"Process must exit before requested information can be determined."}      

following is the code I am using to kill the process.

        private short KillProcess(string processName)
        {
            short count = 0;
            System.Diagnostics.Process[] excelInstances = System.Diagnostics.Process.GetProcesses();
            foreach (System.Diagnostics.Process excelInstance in excelInstances)
            {
                try
                {
                    if (excelInstance.ProcessName == "EXCEL")
                    {
                        excelInstance.Close();
                        excelInstance.Kill();
                    }
                    count += 1;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Write(ex.Message.ToString());
                }
            }
            return count;
        }

thank you so much!!
0
Comment
Question by:pablo_munoz
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
vbturbo earned 500 total points
Comment Utility
hi

Do you have the Google desktop installed? If it's present, it prevents Excel
from shutting down.

else shold your code defently kill excell

vbturbo
    void KillAllExcels() {

        System.Diagnostics.Process proc;

        foreach (proc in System.Diagnostics.Process.GetProcessesByName("EXCEL")) {

            proc.Kill();

        }

    }

Open in new window

0
 
LVL 3

Author Closing Comment

by:pablo_munoz
Comment Utility
Thank you so Much!!
0
 
LVL 3

Author Comment

by:pablo_munoz
Comment Utility
thank you so much!! seems like my code should of worked, was the exception being caused by the Close method of the instance?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now