About wmi

patrol sunp1028 at gmail.com
Tue Jul 15 03:29:11 CEST 2008


Hi,
> 1) I'm not sure if WMI can be forced to close down system processes,
> but if it can it's probably by means of specifying one or more
> privileges when you connect. Try looking in the WMI newsgroups
> for a more general (non-Python) answer to this and I'll happily
> explain how to apply it in a Python context.
I use VBS to kill these processes,the VBS cannot kill these either.

> 2) I can't quite see from this traceback where the problem
> arises. Have you snipped the traceback at all, or was that
> all there was? Can you narrow the thing down to a short
> snippet of code which I'm likely to be able to run independently,
> please?
import wmi
from time import sleep

c = wmi.WMI ()
process_watcher = c.Win32_Process.watch_for("creation")
while True:
	new_process = process_watcher()
	if new_process.Caption == 'notepad.exe':
		print "start killing.."
		sleep(5)
		result = new_process.terminate()
		print "killed"
We must start the notepad.exe manually, then (1) kill the notepad.exe
by this code.
(2)we kill the notepad.exe before this code manually. Both will result
in errors.



More information about the Python-list mailing list