I have a .cmd
file and I want to open it from a python script. The .cmd
file (a converter) does its job when I open it without any further interaction needed in the command window. This means I only have to open it from my script, and that's it.
I tried the following...
from subprocess import check_output
def convert():
subprocess.Popen(['[path to the .cmd file]')
... but it only opens the cmd window for a fraction of a second, and the actual .cmd
file I want to run is not executed. What do I have to change to open the .cmd
file behind my path?
UPDATE
from subprocess import Popen, PIPE
def convert():
process = Popen("cmd.exe", shell=False, universal_newlines=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
commands = r"C:\\CONVERTER\MFD2MAT\\convert.cmd\n"
out, err = process.communicate(commands)