Re: Process.Kill() problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Peter,

Thanks for your response. Sorry for the delay, I got busy with other stuff
at work. When Process.Kill() throws the Win32Exception the NativeErrorCode
is 0x6, "Invalid Handle". I was dumping the handle and it always looks valid
to me. When I use the alternative TerminateProcess() it just returns false
(failure) with no exception.

I think the iexplore.exe cannot be killed for some reason. There may be
subprocesses or parent processes associated with it so Windows doesn't allow
it to be killed? I don't know but that's what I'm speculating. Utilimately
iexplore.exe isn't what I need to kill anyways. When the program I need
becomes available I'll need to kill that and hopefully that won't give me
this problem.

Rick

"Peter Foot [MVP]" <feedback@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23ohR9K9YFHA.3220@xxxxxxxxxxxxxxxxxxxxxxx
> Can you catch the Win32Exception and read it's NativeErrorCode property -
> this should help pin down the cause of the exception - the return value
> from TerminateProcess.
>
> Peter
>
> --
> Peter Foot
> Windows Embedded MVP
> http://www.inthehand.com | http://www.peterfoot.net |
> http://www.opennetcf.org
>
> "Rick" <rtf10@xxxxxxxxxxxxx> wrote in message
> news:pW3me.2476$uu.2413@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>
>> Hi,
>>
>> I'm having a problem using Process.Kill(). I've been getting the
>> Win32Exception "The associated process could not be terminated". I'm
>> using OpenNETCF SmartDeviceFramework 1.3. I know that there was a bug in
>> Process.Kill() before but I assume this has been fixed with the latest
>> version.
>>
>> I'm awaiting an executable that I will start and kill so in the mean time
>> I'm just starting iexplore.exe and trying to kill it to get me going. I'm
>> starting the process with "psi.UseShellExecute = false;" to give me a
>> valid PID. I noticed that I could kill a different process, ceplayer.exe.
>> Why can I kill ceplayer.exe but not iexplore.exe?
>>
>> I tried a work around recommended by Peter Foot. I P/Invoke
>> TerminateProcess() and CloseHandle() but this didn't work either.
>> TerminateProcess always returns failure and the process does not die. I
>> pass TerminateProcess a value of 1 for exitCode which I got from a call
>> to GetExitCodeProcess().
>>
>> Please let me know if I'm doing something wrong. Thank you.
>>
>> Rick
>>
>
>


.



Relevant Pages

  • Process.Kill() problem
    ... Win32Exception "The associated process could not be terminated". ... OpenNETCF SmartDeviceFramework 1.3. ... I'm awaiting an executable that I will start and kill so in the mean time I'm ... TerminateProcess always returns failure and the process does not die. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Process.Kill() problem
    ... > Win32Exception "The associated process could not be terminated". ... > I'm just starting iexplore.exe and trying to kill it to get me going. ... > I tried a work around recommended by Peter Foot. ... > TerminateProcess() and CloseHandlebut this didn't work either. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: pipe channel getting blocked on windows
    ... >the Win32 function TerminateProcessas some kill implementations are, ... > The TerminateProcess function is used to unconditionally cause a process to exit. ... , there's no true mapping for SIGKILL to an exceptional exitcode, but I ...
    (comp.lang.tcl)
  • Re: CreateProcess and TerminateProcess
    ... I want to kill a process that I created with CreateProces. ... So if the createprocess fails, you try to close a handle on an uninitialized variable ... Any program that contains a gratuitous TerminateProcess like this is deeply flawed. ... the application (which you can find by searching the top-level windows and finding the ...
    (microsoft.public.vc.mfc)
  • Re: how to kill word session forcibly...
    ... which has the code to kill the winword session. ... >> The TerminateProcess function is used to unconditionally cause a process to ... >> causes a process to exit, but DLLs attached to the process are not notified ...
    (microsoft.public.word.vba.general)