0

How can I end a process containing a certain keyword, for example

end.process("firefox.exe")

something to that effect.

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219

1 Answers1

0

try this

import psutil

p_name = "firefox.exe"

for p in psutil.process_iter():
    if p.name() == p_name:
        p.kill()
Giampaolo Rodolà
  • 12,488
  • 6
  • 68
  • 60
somesingsomsing
  • 3,182
  • 4
  • 29
  • 46
  • 6
    While this code snippet may solve the question, [including an explanation](//meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, this reduces the readability of both the code and the explanations! – Martin Tournoij Jan 16 '17 at 20:17