killing process in windows

Veronica Tomescu be_veronic at yahoo.com
Thu Jun 9 11:43:21 EDT 2005


Hi Mick,
 
Thanks for your reply.It works fine until killing the process.Wmplayer is started,I can see the process in the task manager list,I also tried with notepad and it's the same problem.
I appreciate if you can help.
Vero


Trent Mick <trentm at ActiveState.com> wrote:
[Miki Tebeka wrote]
> Hello Veronica,
> 
> > I am using Trent's process.py but I have a problem with killing the
> > processes in windows.
> > For example :
> > 
> > import process,time
> > 
> > p=process.ProcessOpen('C:\Program Files\Windows Media
> > Player\wmplayer')
> > time.sleep(3)
> > p.kill()
> > 
> > will start Media Player without terminating it.
> > Any suggestions?
> A brutal way will be to use win32process.TerminateProcess (from win32all
> package - http://starship.python.net/crew/mhammond/).

Miki, actually my process.py *is* using TerminateProcess under the hood
here.

Veronica,
Sorry, I really don't know what might be causing the problem here. Does
your little snippet work properly for other applications like, say,
Notepad, iexplore.exe, Word?

Note that I'm am going to put the path in a list to be sure that the it
gets quoted properly. It *might* be correct as just a string (as you had
it) but I'd have to check.

If you do this in the interactive shell (don't quit the shell):

>>> import process
>>> p = process.ProcessOpen(["C:\Program Files\Windows Media Player\wmplayer"])

Does media player start? Is there a "wmplayer.exe" is the process list
(press Ctrl+Esc to open Task Manager)?

Now try this is the same interactive shell:

>>> p.kill()

Trent

-- 
Trent Mick
TrentM at ActiveState.com

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20050609/a3ef6959/attachment.html>


More information about the Python-list mailing list