Win32: CreateProcess wsetup program problem

emuller at painewebber.com emuller at painewebber.com
Thu Nov 11 18:48:35 EST 1999


I wrote a wrapper to CreateProcess that runs a program with args and
waits until it ends. It works great for most programs (ie..calc,
notepad, net, etc, etc, etc), but when I use it to run a setup.exe
program (NAV 5.0 to be exact), the setup program starts and an exit
value of 0 is returned to me, but the setup program just started. I
figure that the setup program is doing something, then spawning another
process to do the install (a _SETUP.EXE..something or other) and
detaching itself from that process, letting it just run on....

Is there anyone out there who knows how I can pause until that other
program (or whatever happens) is done?

I am using the following code in a module called win32helper.py
(BTW: If anyone would like to use this code, go ahead. I hope to write
a bunch of helper functions and put them here, then post them someday)

import win32api
import win32security
import win32process
import pywintypes
import win32con
import win32event

def RunWait(cmd, args=""):
        pHandle, tHandle, pId, tId = win32process.CreateProcess(cmd," "
+ args,None,None,0,0,None,None,win32process.STARTUPINFO())
        win32event.WaitForSingleObject(pHandle,win32event.INFINITE)
        exitCode = win32process.GetExitCodeProcess(pHandle)
        win32api.CloseHandle(pHandle)
        win32api.CloseHandle(tHandle)
        return exitCode


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list