1

Possible Duplicate:
How do I eliminate Windows consoles from spawned processes in Python (2.7)?

Hi,

In my application I am using external console application. I am catching its output (from std out) and process it. What is happening though that every time I start this application the console window is popping out which is a problem (because I can't use the computer for anything else during the calculations). Is there any way to execute console application, catch its stdout without actually having console window to pop up? The code which is executing the console app:

p = subprocess.Popen([BCALCPATH, "-c", hand, "-t", "a", "-e", "e", "-q", "-d SWNE"], stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
table = p.stdout.read().decode()

All those -c, -t etc. are argument for the console app. BCALCPATH is path to the .exe file. Thanks for help :)

Community
  • 1
  • 1
Piotr Lopusiewicz
  • 2,514
  • 2
  • 27
  • 38
  • Thanks to your reply I've also founded this : http://stackoverflow.com/questions/4703983/module-subprocess-has-no-attribute-startf-useshowwindow; it seems that 3.1.3 have some problems and those flags are not there. Can't find them in docs either though :( – Piotr Lopusiewicz Feb 19 '11 at 18:59
  • 1
    the question you linked has your answer -- those properties were moved to the `subprocess_` module, you just have to get them from there in newer Python versions. – Walter Mundt Feb 19 '11 at 19:51
  • 1
    As the answers to the question you referenced says, you can import `STARTF_USESHOWWINDOW` from `_subprocess` instead of `subprocess`. Or use `pywin32` and import it from `win32process`. Or just use `1`; it's a constant that isn't likely to change. – Nicholas Riley Feb 19 '11 at 19:55
  • Thanks guys; I didn't know about this _subprocess module as it's not in the reference for python 3.1.3. This works like a charm, ty:) – Piotr Lopusiewicz Feb 20 '11 at 12:28

2 Answers2

0

Create a Windows shortcut to the Python script and then set the shortcut's Run property to Minimized.

martineau
  • 119,623
  • 25
  • 170
  • 301
  • It does not worked. How to programatically do the minimized via Python or Java? –  Feb 28 '16 at 05:48
0

You could try using a utility like hstart. You might have to redirect the output to a file and then read from that after the command finishes, though. Cygwin has a similar tool called run.exe if you have that on hand.

Walter Mundt
  • 24,753
  • 5
  • 53
  • 61