Win XP: How to hide command window for sub processes?

Rüdiger Ranft _rdi_ at web.de
Thu Oct 29 06:25:19 EDT 2009


klausfpga schrieb:
> Hi,
> 
> I have a Python script which wants to start a subprocess and wait for
> it to finish.
> 
> However I would like to have NO command window popping up during
> execution.

You need to specify the hide parameter for windows.

import subprocess
kwargs = {}
if subprocess.mswindows:
    su = subprocess.STARTUPINFO()
    su.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    su.wShowWindow = subprocess.SW_HIDE
    kwargs['startupinfo'] = su
process = subprocess.Popen( (r'c:\python25\python.exe',
    r'd:\projekte\bar.py'), **kwargs )




More information about the Python-list mailing list