Skip to content
Advertisement

Is there a way to run a bat file from python and keep going with the execution of the program?

I am running a program where first I run a batch and then I want to do other things which need the script run by batch file to be active.

The problem is that the instructions after the running of the batch are not executed because the execution of the batch script is not terminated.

The code is something like:

subprocess.call([<path_bat_file_to_run>])
# now my batch is running but it waits for following instructions
<other_instructios>
subpprocess.call([<path_bat_file_to_terminate_previous_bat_command>])

How can I fix this problem?

Advertisement

Answer

Try using this:

subprocess.Popen([<path_bat_file_to_run>])

Instead of:

subprocess.call([<path_bat_file_to_run>])

More detailed answer here: Non blocking subprocess.call (by mgilson), Hope i helped you. If not, leave a comment and i’ll try to re-edit this answer.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement