# -*- coding: utf-8 -*- """票 04:分离式起服(Popen DETACHED,立即返回不阻塞终端)。""" import io, sys, subprocess sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') DETACHED = 0x00000008 | 0x00000200 # DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP p = subprocess.Popen( ['cmd', '/c', r'e:\code\crm-backend-matt\.scratch\opportunity-bugfix\t04-start.cmd'], cwd=r'e:\code\crm-backend-matt', creationflags=DETACHED, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) print('launched cmd wrapper pid=', p.pid)