Killing background window when running .exe from Python program
Below is a line from a python program that calls demo.exe. a window for demo.exe opens when it is called, is there a way for demo.exe to run in the "background"? that is, I don't want the window to show for it, I just want demo.exe to run.
p = subprocess.Popen(args = "demo.exe", stdout = subprocess.PIPE)
the output of demo.exe is used by the python program in real time, so demo.exe is not something I can run before running the python program. demo.exe handles a lot of on-the-fly computations. I am using windows xp.
early!
+2
source to share
2 answers
Thanks to fooobar.com/questions/183664 / ... I think this is what you need:
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
p = subprocess.Popen(args = "demo.exe", stdout=subprocess.PIPE, startupinfo=startupinfo)
I tested my Python 2.6 on XP and it does hide the window.
+4
source to share