Terminating a subprocess '.exe'

Ernesto erniedude at gmail.com
Thu Mar 23 18:36:24 EST 2006


I launch a Windows executable and wish to close it from Python.  The
code is below.  Normally, my program waits for rib.exe to finish, but
I'd like to be able to close it from python if possible.  (I suppose if
I was going to do this, I wouldn't use .wait()  )  Any ideas ?

# Launch a program without launching a whole new cmd prompt
def launchWithoutConsole(command, args):
    """Launches 'command' windowless and waits until finished"""
    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    return subprocess.Popen([command] + args,
startupinfo=startupinfo).wait()

ribHandle = launchWithoutConsole("rib.exe",["recovery"])

# Is there a way to close "rib.exe" using ribHandle ?




More information about the Python-list mailing list