0

I want to keep applications that I run using the subprocess library to keep running even after python closes. The following code opens notepad for a short while and then the program closes.

from subprocess import Popen
from time import sleep
Popen('start notepad', shell=True)
sleep(1)

I tried the solutions from the following posts, but none of them work.
Do NOT terminate python subprocess when script ends
Popen waiting for child process even when the immediate child has terminated
os.startfile("notepad") also doesn't work

I am using Windows 10 and would prefer if no other terminal window opened. How can I achieve this behavior?

FieryRMS
  • 91
  • 3
  • 11
  • On Windows only, there is also [`os.startfile()`](https://docs.python.org/library/os.html#os.startfile). That might be what you're looking for instead of `subprocess.Popen`. – ChrisGPT was on strike Feb 05 '22 at 12:08
  • @Chris It still closes afer a while. I also did exactly what the first answer said [here](https://stackoverflow.com/questions/25127561/do-not-terminate-python-subprocess-when-script-ends), could you explain where I am going wrong? – FieryRMS Feb 05 '22 at 12:13
  • That information belongs in your question. Please [edit] it and add details about what you have already tried to show how this question is different from the marked duplicate. – ChrisGPT was on strike Feb 05 '22 at 12:15

0 Answers0