Is there any way to implement an application that close other running application???

help me if there is any way to implement an application that close other running application...

thanks in advance..



Answer this question

Is there any way to implement an application that close other running application???

  • Mike Brown

    It's best to post a close message to a process in order to "ask" it to close. Killing a process abruptly can lead to many problems.

  • chandrala

     peter >>>this is not doing anything ... it does not terminate applications..

    it just like press a free button...

    I do not know what is wrong in it ... I see it coding


  • Yassi

    I think you did not understand me well

    MY application should to close other applications ...

    this is the situation ..

    In my server there are not less than 120 to 150 application running at the same time .. so everyday I try to keep the high performance by restart the server twice aday ..

    and because this huge number of applications .. it takes 2 hours aday just restarting the server because first close each application and restart and then run all applications again...

    so I have emplement a runner application and this helped me so much ... but unfortunatelly I do not know how to implement an application to close the applications(kill them ) how I can do it ...

    thanks in advance...


  • Adamus Turner

    Here:

    System.Diagnostics.Process[] myProcesses;

    myProcesses = Process.GetProcessesByName(@checkedListBox1.CheckedItems.ToString());

    int processCount = myProcesses.Length;

    for(int i = 0; i < processCount; i++)

    {

         

    myProcesses[ i ].Kill();

     

    }

    I hope this will work fine.

    Best Regards,

    Rizwan aka RizwanSharp



  • thegodfather9210

    Peter Ritchie wrote:
    It's best to post a close message to a process in order to "ask" it to close. Killing a process abruptly can lead to many problems.

    can you explain more


  • Mystagogue

    is it something like this ...

    for (int i=0;i<checkedListBox1.Items.Count;i++)

    {

    System.Diagnostics.Process myProcesses;

    myProcesses = Process.GetProcessesByName(@checkedListBox1.CheckedItemsIdea.ToString());

    myProcesses.CloseMainWindow();

    if(!myProcesses.CloseMainWindow())

    {

    myProcesses.Kill();

    }

    }

    actually this code is not working ... could any body help me modify it...


  • Patrik J

    adorer wrote:

    is it something like this ...

    for (int i=0;i<checkedListBox1.Items.Count;i++)

    {

    System.Diagnostics.Process myProcesses;

    myProcesses = Process.GetProcessesByName(@checkedListBox1.CheckedItems.ToString());

    myProcesses.CloseMainWindow();

    if(!myProcesses.CloseMainWindow())

    {

    myProcesses.Kill();

    }

    }

    actually this code is not working ... could any body help me modify it...

    Yes thats it but you dont need to check for for MAin window, Simply do myProcessKill() it'll close that application.

    Best Regards,

    Rizwan aka RizwanSharp



  • Kunk

    Process.Kill will cut the process off at the knees. If it's in the middle of writing a block of data to file it could get cut off in the middle (if it's not an atomic write) and corrupt the file.

    Asking the application to close via CloseMainWindow is the best course of action. If it can't respond then you can think about using Kill:

    Process[] myProcesses;

    myProcesses = Process.GetProcessesByName("Notepad");
    foreach(Process myProcess in myProcesses)
    {
    if(!myProcess.CloseMainWindow())
    {
    process.Kill();
    }
    }

    I would still advise against using Kill. if you're just shutting down the computer, that's overkill and you risk corrupting data.



  • Nikody Keating

    You could post a WM_CLOSE message to the applications main window asking the application to exit. Anything else would terminate the application abruptly and likely leave any opened files in an indeterminate state.

    There's not guarentee that an appplication will/can respond to an WM_CLOSE message.

  • KONJIRO

    rizwan>>>>the same error ... array does not contain definition for kill
  • Will Merydith

    Peter Ritchie wrote:
    You could post a WM_CLOSE message to the applications main window asking the application to exit. Anything else would terminate the application abruptly and likely leave any opened files in an indeterminate state.

    There's not guarentee that an appplication will/can respond to an WM_CLOSE message.

    but how for example microsoft windows do that ...

    for example when you go to task manager and then to processes tab and force the process ( application to end) how that was coded

    I want something like that ..

    thanks again in advance


  • Zapp

    but there is an errors

    if I make it without array as I posted there is an error --->> can not implicity convert type System.Diagnostics.Process[] to

    System.Diagnostics.Process

    and if i make it an array there is another error --->>> system array does not contain a definition for kill

    what shall I doo


  • erikc345

    adorer wrote:
    rizwan>>>>the same error ... array does not contain definition for kill

    Its myProcesses[ i ].Kill(); not myProcesses.Kill();

    You must be trying myProcesses.Kill(); which causes that error.

    Best Regards,

    Rizwan aka RizwanSharp



  • billqu

    Take a Look at the System.Diagnostic.Process Class.

    e.g.

    Process p=Process.GetProcessByName("windord.exe");
    p.Kill();


  • Is there any way to implement an application that close other running application???