killing process in windows

Trent Mick trentm at
Thu Jun 9 17:29:58 CEST 2005

[Miki Tebeka wrote]
> Hello Veronica,
> >    I am using Trent's 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 -

Miki, actually my *is* using TerminateProcess under the hood

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 Mick
TrentM at

More information about the Python-list mailing list