Contents

Python Windows Spawn and Forget Process

Contents

运行一个程序,然后忘记(Detach)它 Taken from here

if 'nt' == os.name:
     p = subprocess.Popen(
         [sys.executable, '-c', cmd], 
         close_fds=True,  # close stdin/stdout/stderr on child
         creationflags=subprocess.DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.CREATE_NO_WINDOW,
     )