Controling the execution of external programs on Win2K

Ben bencr at bigpond.com
Wed Mar 28 00:14:00 EST 2001


Hi,

I placed a post last night looking for a way to run exe's from a Python
programme, where the Python programme waits for each instance of the exe to
finish/return and exit code before proceding with it's next command.

As suggested I have looked at os.system( ) but on Win2K it seems every
external program I execute spawns an external command shell and there
doesn't seem a way to prevent this behaviour ... which is not good (atleast
from what I am trying to do) ...  after a bit more investigation I believe
it is possible to achieve this using the win32process module. I am just
unsure of what args to pass to make it behave in this way.

If anyone could provide further suggestions I would be most grateful :)

# Here is the piece of test code I have been toying with

import win32process



def CreateProcess(commandline):
                              sui = win32process.STARTUPINFO()
                              dummyvalue = win32process.CreateProcess(

None,

commandline,

None,

None,

0,

win32process.NORMAL_PRIORITY_CLASS,

None,

None,

sui)

# Spawns first executable ... python programme pauses until program1.exe
finishes running and closes

 CreateProcess("Programme1.exe /args")

# Once Programme1.exe returns an exit code ... the Python programme resumes
and Programme2 starts

 CreateProcess("Programme2.exe /args") #Once the instance of





More information about the Python-list mailing list