【发布时间】:2017-04-11 10:16:58
【问题描述】:
我想从 shell 执行和终止 Windows 游戏。实际需要是在收到特定命令后使用 Python 启动游戏。我尝试使用以下代码启动游戏。
import subprocess
subprocess.Popen("D:/Entertainement/Games/NFS1/speed.exe",shell=False)
当我运行此代码时,游戏启动并停止,没有任何错误。但是当从 Windows 资源管理器中执行时,同样的游戏运行良好。游戏不需要管理员权限,无需管理员权限即可正常运行。
【问题讨论】:
-
python脚本在哪里运行?在 Windows 服务或 Web 应用程序内部或...?
-
是的。在windows系统里面。作为 websocket 客户端运行
-
您实际上可以反省
Popen完成后发生的事情。见这里 - stackoverflow.com/questions/25079140/… -
@Danish 这是我在程序停止后得到的响应。
Traceback (most recent call last): File "C:\Users\devel\Desktop\temp.py", line 3, in <module> proc = subprocess.check_output("D:/Entertainement/Games/NFS1/speed.exe", stderr=subprocess.STDOUT) File "C:\Python27\lib\subprocess.py", line 573, in check_output raise CalledProcessError(retcode, cmd, output=output) CalledProcessError: Command 'D:/Entertainement/Games/NFS1/speed.exe' returned non-zero exit status -1073741819 -
-1073741819 为
STATUS_ACCESS_VIOLATION(0xC0000005),表示speed.exe进程无法读取、写入或执行内存地址,因为该地址未分配或受保护。