从 lpksetup.exe 开始 Python

Start lpksetup.exe with Python

我尝试从 lpksetup.exe 开始 Python。 我试过了:

subprocess.call(["lpksetup.exe"], cwd="C:\Windows\System32\")
os.startfile('C:\Windows\System32\lpksetup.exe')`

但我总是得到这个错误:

[WinError 2] The system can not find the specified file

路径正确(100% 确定)。当我在资源管理器中搜索文件时,它就在那里(不是隐藏的)但是当我通过 Python 打印目录中的所有文件时,文件不再存在:

import os
for root, dirs, files in os.walk("C:\Windows\System32\"):
    for filename in files:
        print(filename)

如何执行lpksetup.exe?

因为lpksetup.exe似乎是一个可执行文件我认为命令os.system.

关于查找文件:

我不确定,因为我没有在 Windows 上使用 Python,但是 可能 您需要更换 (转义)反斜杠与正常的斜杠,如:

import os
os.system('C:/Windows/System32/lpksetup.exe')

我不得不将文件复制到另一个地方。然后它起作用了。 (Out of System32)