I am working with an older proprietary program where the only way to load the ability to run that program's proprietary commands in the /bin directory is to called a .bat file in cmd.exe, which sets a a variety of variables to then run the commands inside of the /bin directory.
I'm importing various file formats to a list full of components to run inside those proprietary commands, however, the .bat file must be called first and the proprietary commands run directly after in the same cmd.exe session, then close out.
I'm attempting to use subprocess.run to pass a list of commands, but I believe it only allows one command at a time, and can't find a way to load this .bat file and then pass commands into cmd.exe directly afterwards. This is a representative example of what I'm trying:
import subprocess
start_bat_env = 'C:\\Temp\\env_start.bat'
list1 = ['component1A', 'component1B']
list2 = ['component2A', 'component2B', 'component2C']
args = []
args.append(start_bat_env)
for component1 in list1:
args.append('proprietary code ' + component1)
for component2 in list2:
args.append('proprietary code ' + component2)
subprocess.run(args)
Is there a proper way to do this using the subprocess or os libraries to keep one cmd session open loading the .bat and passing everything in directly after?