[Tutor] Hiding/Killing a DOS window (from a previous os.system call)

learner404 learner404 at gmail.com
Mon Mar 5 16:51:42 CET 2007


Hello,

I'm launching an external app through an os.system() or os.popen() but I
don't want the resulting DOS window to hang-on there forever (my python
script is launched with pythonw):
I use a sys.exit() to kill the script who launched the external
app.Thepython script is killed, the app is launched, but the resulting
DOS window
is still there (I have the same result if I use the DOS tskill or taskkill
command to kill the script with his PID).

How could I hide/kill the resulting DOS window  from an os.sytem /
os.popenwith Python ?

Also is there a way to launch an external app. but without os.system and
os.popen to wait there but immediately continue to the next python line (to
avoid this I'm using a thread for now).

As an example I'm using this so far.
If I use pythonw to launch the script, notepad is launched, the script is
killed but the DOS window stay there.

####

import os,sys,time
from thread import start_new_thread

def launchApp():
    os.system("notepad.exe")

try:
    start_new_thread(launchApp,())
except:
    print "Something went wrong => do somenthing"

time.sleep(2)

print "And now going out"
sys.exit()

----

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070305/e9edbdf7/attachment.html 


More information about the Tutor mailing list