How to hide console with Popen on Windows?

Kevin Walzer kw at codebykevin.com
Fri May 18 07:09:02 EDT 2012


On 5/18/12 4:22 AM, xliiv wrote:
> Like the topic, more details in followed links..
>
>
> http://stackoverflow.com/questions/10637450/how-to-hide-console-with-popen-on-windows
>
> http://code.activestate.com/recipes/409002-launching-a-subprocess-without-a-console-window/?c=14452
>
> Please help :(
> Any hint i would appreciate

There are some Windows-specific flags in the subprocess module that you 
can set to control the display of a console window. I use something like 
this:

      self.pscmd=os.path.join(execdir, 'pstools-1.1/txt2ps.exe')
        startupinfo =  subprocess.STARTUPINFO()
         startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
         txtps = self.pscmd  + ' -o ' + tempfile.gettempdir() + 
'\\whois.ps' + ' ' + tmpfile
         subprocess.check_output(txtps, startupinfo = startupinfo)

Hope this helps.
-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com



More information about the Python-list mailing list