Question: How to execute an EXE with Python?

walt whrauser at
Tue Aug 27 19:04:16 CEST 2002


This will keep the dos window open so you can see what is happening.
(Windows 2000)

""" Execute program in cmd window, /k keeps dos window open """
import os
myPy = 'c:/python22/lib/lib-tk/'
os.execl('c:/winnt/system32/cmd.exe', '/k', myPy)

# Could specify path to python if necessary
#os.execl('c:/winnt/system32/cmd.exe', '/k', 'c:/python22/python.exe',

But, I generally use the spawn series, since I want to return to my
script after the program runs.


More information about the Python-list mailing list