Windows 中终止子进程,访问被拒绝
-
import time
import subprocess
from os.path import expanduser
chrome_path = expanduser('~\Local Settings\Application Data\Google\Chrome\Application\chrome.exe')
proc = subprocess.Popen(chrome_path)
time.sleep(4)
proc.terminate()
输出:WindowsError:[错误 5] 访问被拒绝
如何终止 Chrome 进程?
Windows XP 上的 Python 2.6。
-
import time
import subprocess
from os.path import expanduser
chrome_path = expanduser('~\Local Settings\Application Data\Google\Chrome\Application\chrome.exe')
proc = subprocess.Popen(chrome_path)
time.sleep(4)
proc.terminate()
Output: WindowsError: [Error 5] Access is denied
How can I kill the Chrome process?
Python 2.6 on Windows XP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不了解 Windows,但注意到在 Linux 上,Google Chrome 以很少有程序能做到的方式“保护”自身免受操作系统控制信号的影响:
我怀疑这可能是您遇到麻烦的根本原因。顺便说一句,我发布了进程 2345 中的这条注释。
I don't know about Windows, but have noticed on Linux that Google Chrome "protects" itself from operating system control signals in a way that few programs do:
I suspect this may be the root cause of your troubles. Incidentally, I'm posting this note from process 2345.
如果使用 TASKKILL /F /PID [进程 ID 号] 会发生什么?尝试一下。通过导入操作系统启动它
what happens if you use TASKKILL /F /PID [number of process ID] ? Give it a try. Launch it through import OS
我认为最好的选择是在操作系统级别找到并关闭窗口: http:// python.net/crew/skippy/win32/Downloads.html。
I think the best bet is to find and close the window at the os level: http://python.net/crew/skippy/win32/Downloads.html.