starting externel program (win32)

Tim Gahnström /Bladerman tim at bladerman.com
Thu Nov 1 07:45:51 EST 2001


"Marcus Stojek" <stojek at part-gmbh.de> skrev i meddelandet
> from a script I want to start an external program (win32). This should
> be done in a way that is equivalent to typing the  name and options at
> the dos prompt. The program must not be influenced by exiting the
> script.

> Do I have to use system(), spawnv() or spawnve() or something else?

The simplest is to use

os.spawnv(os.P_NOWAIT,"notepad.exe",[])
This will start notepad.exe and return the pid of the process while ypour
script keeps running.

os.spawnv(os.P_WAIT,"notepad.exe",[])
Will wait wile notepad run, when notepad is closed it will return the
exitcode (usually 0)

Look in the os.py for more dokumentation of the variants, ithe doc there is
pretty good I think.

Tim





More information about the Python-list mailing list