Answer the question
In order to leave comments, you need to log in
How to open and close a program with python?
How to open and close any program on windows desktop using python?
I took the Telegram Desktop application as an example, below is the code to open it:
import subprocess
subprocess.call('C:/Users/Johnny/AppData/Roaming/Telegram Desktop/t1/Telegram.exe')
import subprocess
import time
import psutil
time.sleep(5)
for process in (process for process in psutil.process_iter() if process.name()=="Telegram.exe"):
process.kill()
import psutil
for process in (process for process in psutil.process_iter() if process.name()=="Telegram.exe"):
process.kill()
import subprocess
import time
import psutil
subprocess.call('C:/Users/Johnny/AppData/Roaming/Telegram Desktop/t1/Telegram.exe')
time.sleep(5)
for process in (process for process in psutil.process_iter() if process.name()=="Telegram.exe"):
process.kill()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question