How to supress Powershell window when using the -File option
Posted
by guillermooo
on Stack Overflow
See other posts from Stack Overflow
or by guillermooo
Published on 2010-03-07T12:46:42Z
Indexed on
2010/03/08
9:21 UTC
Read the original article
Hit count: 416
I'm calling Powershell like so:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -noninteractive -nologo -file "C:\Users\dummy\Documents\dev\powershell\samples\test.ps1"
I'm calling it from a python script, but the same problem can be observed if called via a shortcut. I thought the -NonInteractive
flag would cause Poweshell to execute in a hidden window, but it doesn't. Is there a way of supressing the console window when calling Powershell from an external application?
Solution based on Johannes Rössel suggestion
st_inf = subprocess.STARTUPINFO()
st_inf.dwFlags = st.inf.dwFlags | subprocess.STARTF_USESHOWWINDOW
Popen(["notepad"], startupinfo=st_inf)
© Stack Overflow or respective owner