I\'m looking to write some code that will kill off a process based on it\'s name and who owns it. This works fine on Windows XP but when I come to run the same code on Windo
the problem is some of the processes does not have names, and therefor you get the error.
If you put that in a try block it will work:
PROCNAME = 'python.exe' for proc in psutil.process_iter(): try: if proc.name == PROCNAME: p = psutil.Process(proc.pid) etc.. except: pass