Possible Duplicate:
Running a process in pythonw with Popen without a console
How do I eliminate Windows consoles from spawned processes in Python (2.7)?
I have a Python program that calls a separate number-crunching program (written in C) as a subprocess several times (using subprocess.check_call). It works great on Linux, and it works great on Windows too except for one little thing: every time it calls the subprocess a Command Prompt window is created and then soon destroyed when the subprocess exits.
This doesn't affect the computation at all, but it's very annoying because this window keeps flashing on and off the screen, and it makes it difficult to do other things on the computer because the new Command Prompt window can steal keyboard focus.
How can I simply execute the subprocess (which has no GUI), and prevent the Command Prompt window from being created?
How are you calling subprocess.check_call()
? If you pass shell=True
then the window should not be created as this will cause the SW_HIDE
flag to be set for the STARTUPINFO.wShowWindow
attribute.
Example:
subprocess.check_call(["ping", "google.com"], shell=True)
When you build the C application, set its type to the Win32 Subsystem instead of the Console Subsystem. If this is a pre-built application, you could change the subsystem with this tool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With