【问题标题】:Python: Calling executable failsPython:调用可执行文件失败
【发布时间】: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 复制到本地目录中,我可以从那里调用它,所以我确定我必须只是在使用目录时做一些菜鸟式的事情。

我应该怎么做?

【问题讨论】:

标签: python windows directory subprocess directory-structure


【解决方案1】:

问题是我使用的是 64 位 Windows,它不使用 System32(从 32 位 Python 运行)。 64 位 Windows 通常使用 SysWOW64 而不是 System32。调用虚拟目录 Sysnative 而不是其中任何一个将根据您正在运行的内容(对我来说,32 位 Python)来确定需要调用哪个目录。 Fsquirt 仅存在于 System32 中,不存在于 SysWOW64 中。这与两者中都存在的记事本之类的东西不同。

subprocess.call("C:/Windows/Sysnative/fsquirt.exe")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-25
    • 1970-01-01
    • 2018-06-08
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多