using subprocess.Popen does not suppress terminal window on Windows

Dave Angel d at davea.name
Wed Sep 12 19:49:31 EDT 2012


On 09/12/2012 11:26 AM, janis.judvaitis at gmail.com wrote:
> Hi, and I'm sorry for using this old thread, but I'm experiencing the same problem, except, that I wan't to execute any shell script or exe without blank terminal window. 
> Is there any way in python to supress blank console screen while script is executing? Multiplatform solution would be nice.
> With best regards, Jānis.
>

it's not clear from your question:  Are you launching non-Python
programs from a python one, using Popen?  If so, I can't help.  It's the
launchee that determines if a console is created, as best as I know. 
However, if you're trying to launch a python program without its getting
a console, then read on.

No need for a multiplatform solution, since the problem is a Windows
one.  Windows will create a console for a new process unless the parent
console is still available (eg. you run it from command line) or unless
the executable is marked with the "no console" flag.  (I don't recall
what that's actually called, I haven't used Windows in a long time).

Anyway, in the Windows version, there are two executables  python.exe
and pythonw.exe.  You want the latter one, either by explicitly naming
it in your launcher (batch file, script, whatever), or by using the .pyw
extension, which is normally associated with the pythonw.exe program.

-- 

DaveA




More information about the Python-list mailing list