hi, here is my script: import win32con import time import wmi c = wmi.WMI() for process in c.Win32_Process(name = "notepad.exe"): print process.ProcessId, process.Name process.Terminate ()
when I have only one notepad.exe process in my system, this works fine, 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: 3156 notepad.exe 6100 notepad.exe Traceback (most recent call last): File "F:\thunder\python\program\wmi\create_terminal_notepad.py", line 16, in module> process.Terminate() File "C:\Python25\Lib\site-packages\wmi.py", line 376, in __call__ handle_com_error (error_info) File "C:\Python25\Lib\site-packages\wmi.py", line 188, in handle_com_error raise x_wmi, "\n".join (exception_string) wmi.x_wmi: -0x7ffdfff7 - 发生意外(ps: exception happened)。 Error in: SWbemObjectEx -0x7ffbeffe - 找不到(ps:Can not found) I don't know why this happend, is there somebody could give me a hand?
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32