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
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
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