I want to open an application with Python, that doesnt close even if the python program stops running... If we take Spotify as an example:
import os
x = "C:\\Users\\49174\\AppData\Roaming\\Spotify\\Spotify.exe"
os.popen(x)
I want to open an application with Python, that doesnt close even if the python program stops running... If we take Spotify as an example:
import os
x = "C:\\Users\\49174\\AppData\Roaming\\Spotify\\Spotify.exe"
os.popen(x)
I guess you need to pass an additional parameter (creationflags
) to Popen
. Something like this should work (however, I do not have a Windows machine to check):
import subprocess
creationflags = subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.subprocess.DETACHED_PROCESS | subprocess.CREATE_NO_WINDOW
x = "C:\\Users\\49174\\AppData\Roaming\\Spotify\\Spotify.exe"
subprocess.Popen(x, creationflags=creationflags)
Try this
import os
os.startfile("C:\\Users\\49174\\AppData\Roaming\\Spotify\\Spotify.exe")