Whenever I am spawning the application using the subprocess.Popen the Windows command line is being launched for a second containing the message that is saying following: The operation completed successfully.

This is really annoying. Is there a way to disable this? Do I have to set the level reporting or what?

有帮助吗?

解决方案

This should work:

si = subprocess.STARTUPINFO()
si.dwFlags=subprocess.STARTF_USESHOWWINDOW
subprocess.Popen(["application.exe"], env=os.environ.copy(), close_fds=True, startupinfo=si)

What it does is tells Popen to use specific parameters (defined by the STARTUPINFO object, si) when starting the process. In this case, it tells it to use si.wShowWindow when creating a new window, and the default value of this is SW_HIDE, so it hides it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top