Open .exe from python 3.8 main

0

I have the following code:

import subprocess
subprocess.run("C:\\Users\\x\\Desktop\\Tool\\Database\\influxd.exe", close_fds=True, creationflags=0x00000010)

When I run it, the window just flashes and does not stay open.

When I run subprocess.run("C:\\Windows\\System32\\calc.exe", close_fds=True, creationflags=0x00000010)

everything is usable and stays open, so I guess it has something to do with the influxd.exe but I can't figure out what it is.

So how can I start an external program and make it independent from my Python program?

python
subprocess
influxdb
asked on Stack Overflow Feb 15, 2021 by chubaka • edited Feb 15, 2021 by dejdej

2 Answers

0

You could try using os module.

[if the py file is within the same directory] import os os.system('start cmd /c "calc.exe"')

answered on Stack Overflow Feb 15, 2021 by Astraisaria
0

Use os module to run .exe file from python script. I ran AnyDesk.exe from my E drive using the following code.

import os

# path = "Path\to\your\exe\file"
path = 'E:\AnyDesk.exe'
os.startfile(path)
answered on Stack Overflow Feb 15, 2021 by Md. Zahangir Alam

User contributions licensed under CC BY-SA 3.0