我有一些传感器供应商提供给我的 .exe 应用程序。它们允许我在特定时间抓取数据并转换文件类型。但是,我需要手动通过 cmd 运行它们,并且我正在尝试使用 Python 自动化该过程。我无法让这个工作。
到目前为止,我有:
import sys
import ctypes
import subprocess
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
if is_admin():
process = subprocess.Popen('arcfetch C:/reftek/arc_pas *,2,*,20:280:12:00:000,+180', shell=True, cwd="C:/reftek/bin",
stdout=subprocess.PIPE, stderr=subprocess.PIPE,)
out = process.stdout.read()
err = process.stderr.read()
else:
# Re-run the program with admin rights
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
但是,“arcfetch” exe 没有运行。此外,这需要我允许 Python 每次都对硬盘进行更改,这不会自动工作。
任何帮助将不胜感激!