我已经讨论这个问题很长时间了。我有一个命令行,我想通过python运行:
Usersname.lastnameDesktopTESTERLatitude 5431Latitude-5431-46KCM_Win10_1.0_A01.exe /s /e=C:Usersname.lastnameDesktopTESTERLatitude 5431
这应该运行.exe,然后将文件提取到指定的文件夹中。我在操作系统上尝试过,它很有效,但当我用运行它时
import subprocess
x = '"' + "\Users\name.lastname\Desktop\TESTER\Latitude 5431\Latitude-5431-46KCM_Win10_1.0_A01.exe" + '" ' + "/s /e=C:Users\name.lastname\Desktop\TESTER\Latitude 5431"
p1 = subprocess.run(x, shell=True)
它只向我显示这样的"提示",但没有错误消息,.exe也没有执行。
Pass command line arguments directly to vendor installer.
Turn the return code to success if required
Latitude-5431-46KCM_Win10_1.0_A01.exe /factoryinstall /passthrough D:Sample.xml C:logFI.log
Change from the default log location to C:my path with spaceslog.txt
Latitude-5431-46KCM_Win10_1.0_A01.exe /l="C:my path with spaceslog.txt"
Force update to continue, even on "soft" qualification errors
Latitude-5431-46KCM_Win10_1.0_A01.exe /s /f
尝试在没有shell=True
的情况下运行,因为这会使事情变得更复杂,而不是帮助:
import subprocess
prog = r"C:Usersname.lastnameDesktopTESTERLatitude 5431Latitude-5431-46KCM_Win10_1.0_A01.exe"
args = ["/s", r"/e=C:Usersname.lastnameDesktopTESTERLatitude 5431"]
subprocess.run([prog]+args)