【发布时间】:2016-02-25 00:27:12
【问题描述】:
我正在尝试在 Python 中运行其中任何一个...
subprocess.call(r"C:\Windows\System32\fsquirt.exe", shell=True)
subprocess.call("C:\\Windows\\System32\\fsquirt.exe", shell=True)
subprocess.call(r"C:/Windows/System32/fsquirt.exe", shell=True)
subprocess.call("C:/Windows/System32/fsquirt.exe", shell=True)
它们都会导致...
'C:/Windows/System32/fsquirt.exe' is not recognized as an internal or external command,
operable program or batch file.
如果我只是将 fsquirt.exe 复制到本地目录中,我可以从那里调用它,所以我确定我必须只是在使用目录时做一些菜鸟式的事情。
我应该怎么做?
【问题讨论】:
-
您的程序是否有权限执行 System32 目录中的文件?
-
(1) 可能与"File System Redirector"有关。尝试
Sysnative而不是System32。 (2) 你不需要shell=True,使用它的完整路径运行命令 -
啊啊啊那行得通。多谢了。 subprocess.call("C:/Windows/Sysnative/fsquirt.exe")
-
如果有效; post it as an answer(请提及您的 Windows 版本(64 位)、python 可执行版本(32 位))。
标签: python windows directory subprocess directory-structure