Solved

Cannot end process

Posted on 2007-11-20
3
1,127 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
ID: 20321971
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
ID: 31410163
Thank you so Much!!
0
 
LVL 3

Author Comment

by:pablo_munoz
ID: 20322278
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

803 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