[英]Python: Calling executable fails
I'm trying to run any one of these in Python... 我正在尝试在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)
They all result in... 他们都导致...
'C:/Windows/System32/fsquirt.exe' is not recognized as an internal or external command,
operable program or batch file.
If I just copy fsquirt.exe into the local directory I can call it from there, so I'm sure I must just be doing something noob-ish with how I'm using directories. 如果我只是将fsquirt.exe复制到本地目录中,则可以从该目录中调用它,因此,我确定我对目录的使用方式必须做得有些愚蠢。
How should I do this? 我应该怎么做?
The problem was that I'm using 64 bit Windows which doesn't use System32 (running from 32bit Python). 问题是我正在使用不使用System32的64位Windows(从32位Python运行)。 64 bit Windows typically uses SysWOW64 instead of System32. 64位Windows通常使用SysWOW64而不是System32。 Calling the virtual directory Sysnative instead of either of those will sort out which one needs to be called based on what you're running (for me, 32bit Python). 调用虚拟目录Sysnative而不是这两个目录中的任何一个,将根据您所运行的内容(对我而言,是32位Python)来确定需要调用哪个虚拟目录。 Fsquirt exists only in System32, not SysWOW64. Fsquirt仅存在于System32中,而不存在于SysWOW64中。 This is different to something like Notepad which exists in both. 这与两者中都存在的类似记事本的东西不同。
subprocess.call("C:/Windows/Sysnative/fsquirt.exe")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.