0

I was wondering if any of you know how to create a python code that would terminate a certain process, im thinking a list of them (chrome.exe, Microsoft edge, etc) if the program gets user input. Is this even possible? The idea is that the python code will be reading a text file for certain words or phrases the user inputs and if detected, it will terminate (or crash) the other program. I am relatively new to the world of python so please go easy on me. Thanks!

B-hads
  • 67
  • 6
  • On Linux, see https://stackoverflow.com/questions/15080500/how-can-i-send-a-signal-from-a-python-program On Windows, use `subprocess` with `taskkill` command and admin rights may be easier. – Aaron May 22 '20 at 21:25

1 Answers1

1

Here is the code:

import os

os.system("tasklist > 1.csv")
with open("1.csv", "r") as f:
    print(f.read())
task = input("Enter process: ")
os.system("taskkill /f /im "+task)
Red
  • 26,798
  • 7
  • 36
  • 58