kiryha
kiryha

Reputation: 193

How to run the code in command line application via Python

I need to run a bat file (P:/myBat.bat) in a specific application (for example, located in C:/temp/myApp.exe). Manually I launch myApp.exe, run the code

hscript P:/myBat.bat

And I get what I need. But I wish to do it with Python.

I know how to execute a bat file with Python:

import subprocess
subprocess.Popen("P:/myBat.bat").communicate()

But how to execute hscript P:/myBat.bat via myApp.exe with Python?

Upvotes: 0

Views: 63

Answers (1)

Max Gasner
Max Gasner

Reputation: 1256

You are looking for subprocess.call, e.g. subprocess.call(['hscript', 'P:/myBat.bat']), and its friends. See: https://docs.python.org/3/library/subprocess.html#subprocess.call

Upvotes: 1

Related Questions