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

Martin P. Hellwig martin.hellwig at dcuktec.org
Thu Oct 29 07:37:32 EDT 2009


Chris Rebert wrote:
> On Thu, Oct 29, 2009 at 3:25 AM, Rüdiger Ranft <_rdi_ at web.de> wrote:
>> 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 )
> 
> Interestingly, none of that appears to be documented. 

Except for here:
http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx

> I smell a docs bug waiting to be reported.
> 
> Cheers,
> Chris
> --
> http://blog.rebertia.com

-- 
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'



More information about the Python-list mailing list