How to Close a program using python?
If you're using Popen
, you should be able to terminate the app using either send_signal(SIGTERM)
or terminate()
.
See docs here.
# I have used subprocess comands for a while
# this program will try to close a firefox window every ten secounds
import subprocess
import time
# creating a forever loop
while 1 :
subprocess.call("TASKKILL /F /IM firefox.exe", shell=True)
time.sleep(10)