python调用bat 整理

bat文件内容:

md D:\Word\A 

echo Hello world!
echo show %aaaas1%

msg %username% /time:10 aaaaabbbbbbcc

==============================================================================

==============================================================================

#python 调用bat文件夹
import subprocess
#cmd = 'cmd.exe c:\\sam.bat'
p = subprocess.Popen("cmd.exe /c" + "c:\\sam.bat abc", stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

curline = p.stdout.readline()
while(curline != b''):
    print(curline)
    curline = p.stdout.readline()

p.wait()
print(p.returncode)

你可能感兴趣的:(python,python,bat)