Automatically running CMD after python script running::

Viewed 43

I have a python script and would like to open CMD and run another exe app after finishing with python script.. I have been trying to use os system and subprocess and read the forum, however can not find how to run another .exe app in the cmd I got the following rror: command is not recognized as an internal or external command operable ... I attached the script:

import numpy as np
import os
import subprocess
import sys


 L_b          =          int(input("PLEASE ENTER LENGTH OF BEAM: "))                                                                              
 xf           =          L_b+3
 print(xf)
 p = subprocess.Popen(["cmd", "NAMEOFAPP.exe",shell = True)
 #p = subprocess.call(["NAMEOFAPP"], shell = True)
 #os.system("start /B start NAMEOFAPP.exe @cmd /k {NAMEOFAPP.exe}")
1 Answers

Try this:

import os
os.chdir("C:/path/to/the/file") ## Do this if you're not currently in the directory that contains the .exe file
os.system("start NAMEOFAPP.exe") ## This command runs the app
Related