subprocess.Popen spawning cmd shells

M

Mrown

Hi,
I'm currently writing a python program that relies on a CLI
program. What I'm currently doing is using subprocess.Popen on Python
2.5.1. Here's the line that I'm currently running:

child = subprocess.Popen(["c:\app.exe", node, "-w",
str(tmpTime * 1000), '-n', str(1), '-l'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)

The problem is that although the above works, a CMD shell is spawned
and becomes visible for each time I run the above. I thought that by
redircting stdin, stdout and stderr, no CMD shell should pop-up. Is
something wrong in the way I'm using subprocess? Thanks for your help.
 
M

Mrown

Hi,
  I'm currently writing a python program that relies on a CLI
program.  What I'm currently doing is using subprocess.Popen on Python
2.5.1.  Here's the line that I'm currently running:

            child = subprocess.Popen(["c:\app.exe", node, "-w",
str(tmpTime * 1000), '-n', str(1), '-l'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)

The problem is that although the above works, a CMD shell is spawned
and becomes visible for each time I run the above.  I thought that by
redircting stdin, stdout and stderr, no CMD shell should pop-up.  Is
something wrong in the way I'm using subprocess?  Thanks for your help.

To anyone interested, I found the solution by using the
CREATE_NO_WINDOW creation flag. So this is what the code now looks
like (and it doesn't spawn any shells):

CREATE_NO_WINDOW = 0x8000000
child = subprocess.Popen(["c:\app.exe", node, "-w",
str(tmpTime * 1000), '-n', str(1), '-l'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags =
CREATE_NO_WINDOW)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top