[python-win32] list/kill processes on Win9x and NT+...

sebastien Pastor spastor at center.com
Wed Jul 13 18:37:25 CEST 2005


I am using wmi  and win32api.

so it goes like  :

import wmi
c = wmi.WMI ()
        try:
            for p in c.Win32_Process ():
                if p.Name=="process.exe":
                    print "killing  " + str(p.ProcessId) + str(p.Name)
                    win32api.TerminateProcess(handle,-1)
                    win32api.CloseHandle(handle)


        except win32api.error:
             blablabla

Hope this helps ..

Cheers

seb


Gabriel Genellina wrote:

>At Wednesday 13/7/2005 00:30, RayS wrote:
>
>  
>
>>Ah, now I just found after searching for "CreateToolhelp32Snapshot"
>>http://sourceforge.net/mailarchive/message.php?msg_id=8291643
>>    
>>
>>>>Does anyone have a way to list/kill without the external process that 
>>>>        
>>>>
>>works in all 9x and XP?
>>    
>>
>>>PDH will work for NT, 2000 and up. For Win95/98 you can enumerate 
>>>      
>>>
>>processes using ToolHelp32: http://support.microsoft.com/kb/q175030/
>>    
>>
>
>If you eventually craft a function for enumerating all processes which 
>works on all platforms, would be nice if you could post it here...
>
>
>Gabriel Genellina
>Softlab SRL 
>
>_______________________________________________
>Python-win32 mailing list
>Python-win32 at python.org
>http://mail.python.org/mailman/listinfo/python-win32
>
>
>  
>



More information about the Python-win32 mailing list