Python Forum

Full Version: EXE file inside the loop
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a python loop, inside the loop, it calls an exe file.
What I want is every time when the exe file finishes the execution, then start the next iteration,
but now all the exe files runs almost together.
What should I do?

for file in folders:
  remote_path = '/miadmfggp_live/' + file
  local_path =  "C://yardi_backup//zip//"+file
  os.system("start C:\yardi_backup\yardi_download.exe {} {}".format(remote_path,local_path))
It is advised to generally avoid os.system when you can and use subprocess instead to execute programs.
You might try with something like:
for file in folders:
  remote_path = '/miadmfggp_live/' + file
  local_path =  "C://yardi_backup//zip//"+file
  process = subprocess.Popen("start C:\yardi_backup\yardi_download.exe {} {}".format(remote_path,local_path))
  process.wait()