This is something I've used in the past to accomplish this. Assuming this code in a file and named NoWindowSubProc.py
# use:
# from NoWindowSubProc import subprocess
# subprocess.Popen(... etc...
# subprocess.Popen([exe_path, arg])
def _get_startup_info():
"""Launches 'command' windowless"""
import subprocess
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
return startupinfo
_startup_info = _get_startup_info()
class _subprocess_atr(object):
def __init__(self, atr):
self.atr = atr
def __call__(self, *args, **kw):
return self.atr(*args, startupinfo=_startup_info, **kw)
class subprocess(object):
def __getattr__(self, atr):
import subprocess, inspect
atr = getattr(subprocess, atr)
if inspect.isroutine(atr):
return _subprocess_atr(atr) # if the attribute is a method, add windowless startup info
return atr # not a method, return the normal attribute
subprocess = subprocess()