Re: Process.Kill() problem
- From: "Rick" <rtf10@xxxxxxxxxxxxx>
- Date: Thu, 02 Jun 2005 02:30:07 GMT
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
>>
>
>
.
- Follow-Ups:
- Re: Process.Kill() problem
- From: Paul G. Tobey [eMVP]
- Re: Process.Kill() problem
- Prev by Date: [Pocket PC Phone Edition] accessing the modem/data stream
- Next by Date: Re: Thanks to those who help
- Previous by thread: [Pocket PC Phone Edition] accessing the modem/data stream
- Next by thread: Re: Process.Kill() problem
- Index(es):
Relevant Pages
|