[issue30082] hide command prompt when using subprocess.Popen with shell=False on Windows

Eryk Sun report at bugs.python.org
Sat Oct 16 19:27:43 EDT 2021


Eryk Sun <eryksun at gmail.com> added the comment:

The force_hide option could also force the use of a new hidden window, even if the current process has a console. That way the output is always hidden. For example:

    if force_hide or shell:
        if force_hide and not (creationflags & _winapi.DETACHED_PROCESS):
            creationflags |= _winapi.CREATE_NEW_CONSOLE
        startupinfo.dwFlags |= _winapi.STARTF_USESHOWWINDOW
        startupinfo.wShowWindow = _winapi.SW_HIDE

One can also use CREATE_NO_WINDOW to create a console that has no window, as opposed to a hidden window. For example:

    if force_no_window:
        if creationflags & _winapi.CREATE_NEW_CONSOLE:
            raise ValueError('force_no_window cannot be used with '
                             'CREATE_NEW_CONSOLE')
        creationflags |= _winapi.CREATE_NO_WINDOW

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue30082>
_______________________________________


More information about the Python-bugs-list mailing list