0

我目前有以下代码:

 processlist = []
    for p in psutil.process_iter():
        try:
            process = psutil.Process(p.pid)
            pname = process.name()
            processlist.append(pname)
        except:
            pass
    if "tor.exe" in processlist:
        os.system("Taskkill /im tor.exe")
    process = subprocess.Popen(r"C:\Program Files (x86)\Tor Browser\Browser\firefox.exe", stdout=subprocess.PIPE)

本质上,我希望 Python 代码在 Tor 浏览器打开时杀死它,然后重新打开它。尽管如此,当我运行此代码时,Tor 浏览器会显示一条消息,指出浏览器存在错误,用户是否希望关闭并重新启动浏览器?我真的不希望这种情况发生,所以我只是想知道是否有另一种关闭浏览器的方法来避免此确认提示消息?

4

1 回答 1

0

Type taskkill /?

All you are doing is asking Tor (whatever that is) to close, ie send a WM_Close message. /f terminates an application.

于 2015-04-11T20:08:37.023 回答