这是我正在尝试做的...从网络下载一个 exe 静默安装 运行下载的 exe 并传递一个参数我的代码是import urllib.requestimport shutilimport subprocessimport osfrom os import systemurl = "https://downloads.com/App.exe"output_file = "C:\\files\App.exe"with urllib.request.urlopen(url) as response, open(output_file, 'wb') as out_file: shutil.copyfileobj(response, out_file)# Silent Installsubprocess.call("C:\\files\App.exe /SILENT ")system("C:\\Program Files (x86)\\files\App.exe -ARG")当我运行它时,它会下载 exe,然后安装 exe,但在尝试 exe 下载的文件时失败并出现此错误'C:/Program' is not recognized as an internal or external command,operable program or batch file.
2 回答
MMTTMM
TA贡献1869条经验 获得超4个赞
尝试替换:
system("C:\\Program Files (x86)\\files\App.exe -ARG")
经过: subprocess.call("C:\\Program Files (x86)\\files\App.exe -ARG")
慕的地8271018
TA贡献1796条经验 获得超4个赞
使用以下解决
import urllib.request
import shutil
import subprocess
import os
from os import system
url = "https://downloads.com/App.exe"
output_file = "C:\\files\App.exe"
with urllib.request.urlopen(url) as response, open(output_file, 'wb') as out_file:
shutil.copyfileobj(response, out_file)
# Silent Install
subprocess.call("C:\\files\App.exe /SILENT ")
subprocess.call(['C:\\Program Files (x86)\\files\App.exe', '-ARG'], shell=True)
添加回答
举报
0/150
提交
取消