Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call an executable as independent process using python in windows

After calling an exe using python script in windows, the exe should run independent of this python script and once it is initiated the control should comeback to python script and executes the further script and control of .py file will die. But on other side before finishing execution, the exe should call this python script.

Ideas would be highly appreciated.

I have tried following commands:

  1. os.system("start test.exe")
  2. os.startfile("test.exe")
  3. os.spawnlv(os.P_NOWAIT, "test.exe")
  4. os.spawnv(os.P_NOWAIT, 'C:\Python31\python.exe', ('python', 'test.py'))
  5. os.execvp("python3", ("test.py", ))
like image 823
mak Avatar asked Mar 05 '26 22:03

mak


1 Answers

I sounds as if you want the callee to callback the caller (sorry for the alliteration :) Since you are using Python 3.1 maybe the subprocess module will provide the intended behavior. It is not a true callback per se, but the calling program can perform decisions based on the output of the called program (exe in this case.)

like image 83
T.P. Avatar answered Mar 07 '26 12:03

T.P.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!