Search code examples
pythonpython-3.xsubprocesspopen

Subprocess not opening files


I am writing a program to open other programs for me. os.system() would always freeze my app, so I switched to subprocess.

I did some research and this is how a tutorial told me to open a program.

I have only replaced the path for my variable, which contains the path.

After I run this, only a commabd prompt window opens and nothing else. How can I fix this?

Code:

from subprocess import Popen
filename1 = "C:/Program Files/Google/Chrome/Application/chrome.exe"
Popen(["cmd", "/c", "start", filename1)

Solution

  • import subprocess
    filename1 = "C:\Program Files\Google\Chrome\Application\chrome.exe"
    subprocess.Popen(filename1)