hi, here is my script:<br><br>import win32con<br>import time<br>import wmi<br>c = wmi.WMI()<br>for process in c.Win32_Process(name = "notepad.exe"):<br> print process.ProcessId, process.Name<br> process.Terminate
()<br><br>when I have only one notepad.exe process in my system, this works fine,<br>but
when I have more than one notepad.exe , after terminal the first
notepad.exe, the Terminate() for the second notepad.exe process will
generate the following error:
<br><br>3156 notepad.exe<br>6100 notepad.exe<br>Traceback (most recent call last):<br> File "F:\thunder\python\program\wmi<div id="mb_0">\create_terminal_notepad.py", line 16, in<br>module><br> process.Terminate
()<br> File "C:\Python25\Lib\site-packages\wmi.py", line 376, in __call__
<br> handle_com_error (error_info)<br> File "C:\Python25\Lib\site-packages\wmi.py", line 188, in handle_com_error<br> raise x_wmi, "\n".join (exception_string)<br>wmi.x_wmi: -0x7ffdfff7 - 发生意外(ps: exception happened)。
<br> Error in: SWbemObjectEx<br> -0x7ffbeffe - 找不到(ps:Can not found)<br><br><br>I don't know why this happend, is there somebody could give me a hand?</div>