[Tutor] Hiding/Killing a DOS window (from a previous os.system call)
Alan Gauld
alan.gauld at btinternet.com
Mon Mar 5 18:38:46 CET 2007
"learner404" <learner404 at gmail.com> wrote
> 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
Try using os.spawnl() instead:
>>> pid = os.spawnl(os.P_NOWAIT,r'C:\Windows\System32\notepad.exe')
>>> print pid
2834
The P_NOWAIT makes it return immediately, and no DOS box
is created.
Note that the spawn family of processes are deprecated and the
subprocess module provides equivalent functionality.
Using subprocess it looks like:
>>> pid = Popen([r'C:\Windows\System32\notepad.exe', ""]).pid
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list