私は次のようにPowershellを呼び出しています:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -noninteractive -nologo -file "C:\Users\dummy\Documents\dev\powershell\samples\test.ps1"
Python スクリプトから呼び出していますが、ショートカット経由で呼び出した場合も同じ問題が発生します。-NonInteractive
このフラグにより、非表示のウィンドウで Poweshell が実行されると思いましたが、そうではありません。外部アプリケーションから Powershell を呼び出すときにコンソール ウィンドウを非表示にする方法はありますか?
Johannes Rössel の提案に基づくソリューション
import subprocess
st_inf = subprocess.STARTUPINFO()
st_inf.dwFlags = st_inf.dwFlags | subprocess.STARTF_USESHOWWINDOW
subprocess.Popen(["notepad"], startupinfo=st_inf)