Cross-platform subprocess with hidden window

后端 未结 4 1123
陌清茗
陌清茗 2020-11-28 08:18

I want to open a process in the background and interact with it, but this process should be invisible in both Linux and Windows. In Windows you have to do some stuff with S

4条回答
  •  囚心锁ツ
    2020-11-28 08:34

    You can turn your code into:

    params = dict()
    
    if os.name == 'nt':
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        params['startupinfo'] = startupinfo
    
    proc = subprocess.Popen(command, **params)
    

    but that's not much better.

提交回复
热议问题