现在我用pythonw.exe运行我的scrypt,当执行以下命令时,cmd出现:
r = subprocess.call('net stop tomcat7', shell=False)
print r
如何在代码执行时不显示cmd?
答案 0 :(得分:0)
尝试设置shell参数'True'。
r = subprocess.call('net stop tomcat7', shell=True)
print r
答案 1 :(得分:0)
我将这个startupinfo用于subprocess.Popen(在this project中):
subprocess.STARTF_USESHOWWINDOW = 1
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
subprocess.Popen(
[app] + args,
startupinfo=startupinfo,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE)