简体   繁体   English

使用python中的bat文件执行exe文件

[英]Execute exe-file with bat-file from Python

I have an exe-file that I need to run several times with different parameters. 我有一个exe文件,需要使用不同的参数运行几次。 I can manually (or with Python) create a bat-file with all the parameters and then run the exe-file 我可以手动(或使用Python)使用所有参数创建一个bat文件,然后运行exe文件

C:\\RAY\\Reflec.exe < test.bat C:\\ RAY \\ Reflec.exe <test.bat

in a cmd window but I run into problems when I try to make Python run it. 在cmd窗口中,但是当我尝试使Python运行它时遇到了问题。 The exe-file is executed but it does not take in the parameters in the bat-file. 该exe文件已执行,但不接受bat文件中的参数。 I have tried various ways, eg using os.startfile, subprocess.call, and so on but I can not get it to work. 我尝试了各种方法, 例如使用os.startfile,subprocess.call等,但无法正常工作。 All I achieve is to run the exe-file but then it is waiting for the parameters. 我所能实现的就是运行exe文件,但是它正在等待参数。 I don't get any error messages. 我没有收到任何错误消息。

Can someone please help me with the syntax? 有人可以帮我语法吗? Thanks. 谢谢。

import os
os.system("D:/Ramesh/test.bat")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM