Reputation: 2832
I have a .bat
file with parameters; I run it using os.startfile(test.bat)
. Is there a way to hide its console? I tried using subprocess
, it works well but when I close the parent program the subprocess
that was compiled using py2exe
console mode closes too.
info = subprocess.STARTUPINFO()
info.dwFlags=1
info.wShowWindow=0
subprocess.Popen(test.bat,startupinfo=info)
Thanks
Upvotes: 3
Views: 4558
Reputation: 90989
Use shell=True
and creationflags=subprocess.SW_HIDE
with subprocess.Popen
. This worked for me
subprocess.Popen(['test.bat'], shell=True, creationflags=subprocess.SW_HIDE)
In some releases of Python, SW_HIDE
is not available in subprocess
module. In that case, you may have to use _subprocess.SW_HIDE
Upvotes: 8