shell - Window does not close when Python script on Windows is finished, until launched program exits -


the follwing python script works fine, exept shell window remains open.

file = open("c:\\documents , settings\\user1\\desktop\\bpanel\badepanel\\steelusage.bsu", "a+") input = raw_input("please enter project name:") input = input.upper () line in file.readlines():         if input in line:             print "project name exists, executing badepanel"             import time             time.sleep(4)             import subprocess             subprocess.call(['c:\\documents , settings\\user1\\desktop\\bpanel\badepanel\\badepanel.exe'])             exit(subprocess) file.write (input+"\n") print "project name written file, executing badepanel" import time time.sleep(4) import subprocess subprocess.call(['c:\\documents , settings\\user1\\desktop\\bpanel\badepanel\\badepanel.exe']) exit(subprocess) file.close() 

the shell window terminates ony after close exeuted progrm (badepanel.exe)
script display printed text in shell window, wait 4 secs, execute program, , exit.
thanks

from doc:

subprocess.call()

run command described args. wait command complete, return returncode attribute.

so .call() function ever returns after badepanael.exe finishes.

instead, try:

print "project name written file, executing badepanel" time.sleep(4) subprocess.popen(['c:\\documents , settings\\user1\\desktop\\bpanel\badepanel\\badepanel.exe']) sys.exit(0) 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -