我有与其他Windows 程序交互的python 脚本。有时,该程序崩溃,并且脚本中出现错误。如何关闭该程序并重新启动?
答案 0 :(得分:0)
此代码对我有用
import subprocess
subprocess.call(["taskkill", "/F", "/T", "/IM", "progname.exe"]) # forced killing, with childs, by name
subprocess.Popen([r"C:\Path\To\Folder\progname.exe", "--fast"])