0

Now I'm running my scrypt with pythonw.exe and when the following command is executing cmd appears:

r = subprocess.call('net stop tomcat7', shell=False)
print r

How to make cmd not appear when code executing?

Ashwini Chaudhary
  • 244,495
  • 58
  • 464
  • 504

2 Answers2

0

Try to set shell parameter 'True'.

r = subprocess.call('net stop tomcat7', shell=True)  
print r
fliedonion
  • 912
  • 8
  • 13
0

I used this startupinfo with subprocess.Popen (in 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)
Jason Sperske
  • 29,816
  • 8
  • 73
  • 124