错误 2,'CreateProcess','The system cannot find the file specified.' - pywinauto

Error 2, 'CreateProcess', 'The system cannot find the file specified.' - pywinauto

我尝试运行这个代码:

from pywinauto.application import Application
app = Application(backend="uia").start(r"C:\Users\MyUser\AppData\Local\Apps.0\QD7PJO40.EAZ\MyApp.exe")

我试过添加“/”,添加“\”,删除“backend = uia”。我确认可以使用 cmd.exe 打开该应用程序。我一直收到错误消息:

无法创建进程... CreateProcess 返回错误:(2, 'CreateProcess', 'The system cannot find the file specified.')

我还读到也许我应该在 64 位系统上禁用文件系统重定向器,但我不知道该怎么做,或者它是否会产生影响,因为这个文件不在 C: \WINDOWS\system32。请帮忙!

您可以这样解决:

app = Application(backend="uia").start(r"cmd /c your.exe", wait_for_idle=False)
app = Application(backend="uia").connect(path="your.exe")