locked
Exe killer RRS feed

  • Question

  • hello,

    i have launch several exe through ShellExecuteExSHELLEXECUTEINFO ShExecInfo = {0};

     ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);

      ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;

      ShExecInfo.hwnd = NULL;

      ShExecInfo.lpVerb = NULL;

      ShExecInfo.lpFile = L"\\Program Files\\abc.exe";

      ShExecInfo.lpParameters = L"";

      ShExecInfo.lpDirectory = NULL;

      ShExecInfo.nShow = SW_SHOW;

      ShExecInfo.hInstApp = NULL;

      ShellExecuteEx(&ShExecInfo);

    WaitForSingleObject(ShExecInfo.hProcess,0); now i want to kill that abc.exe how i manage it? is there any api for that killing exe?

    Thanks in advance

    Regards

    Salman

    Monday, September 11, 2006 3:19 PM

Answers

  • Hello,

    kuntushi i stop exe in this Manner. 

    IsProcessRunning function is present in my first Post.

    ID = IsProcessRunning("abc.exe");

    hnd = OpenProcess(PROCESS_ALL_ACCESS,FALSE,ID);

    if (hnd != NULL)

    {

        GetExitCodeProcess(hnd,&ecode);

         TerminateProcess(hnd,ecode);

         CloseHandle(hnd);

    }

    Its working

    Regards

    Salman

    Friday, September 15, 2006 9:00 AM

All replies

  • So you wanna kill it after the wait, or wait until it's killed by something else?

    If you want to kill it after the wait (which it looks like, because you are waiting for 0 seconds), have you just tried CloseHandle(ShExecInfo.hProcess)?  If you want to wait there forever until it is stopped, then you'll need another thread that stops the executable.

    I've never done this stuff, so it could not work.  But worth a try while you wait for a more confident response.

    Monday, September 11, 2006 10:54 PM
  • TerminateProcess is the API to use.
    Thursday, September 14, 2006 11:58 PM
  • I'm glad you're here Alex, I keep telling people the wrong things to use
    Friday, September 15, 2006 12:02 AM
  • Hello,

    kuntushi i stop exe in this Manner. 

    IsProcessRunning function is present in my first Post.

    ID = IsProcessRunning("abc.exe");

    hnd = OpenProcess(PROCESS_ALL_ACCESS,FALSE,ID);

    if (hnd != NULL)

    {

        GetExitCodeProcess(hnd,&ecode);

         TerminateProcess(hnd,ecode);

         CloseHandle(hnd);

    }

    Its working

    Regards

    Salman

    Friday, September 15, 2006 9:00 AM