基本形(返り値あり※プログラム内から呼ぶと本体が止まる)
import subprocess
cmd = [cmd1,cmd2]
p=subprocess.Popen(cmd,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,creationflags=0x08000000)
stdout,stderr = p.communicate()
out = stdout.decode('cp932')
err = stderr.decode('cp932')
基本形(返り値なし※投げっぱなしで本体は続行する)
import subprocess
cmd = [cmd1,cmd2]
subprocess.Popen(cmd,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,creationflags=0x08000000)
プロンプトウィンドウを表示させないサンプル
import subprocess
cmd = [cmd1,cmd2]
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
p = subprocess.Popen(cmd,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,startupinfo=startupinfo)
stdout,stderr = p.communicate()