Question: How to execute an EXE with Python?
Fausto Arinos de A. Barbuto
fbarbuto at telusplanet.net
Tue Aug 27 16:41:09 EDT 2002
Hi Walt,
Amazing, that doesn't work either. I get the following
message instead:
Traceback (most recent call last):
File "C:\PROGRA~1\PYTHON\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line
301, in RunScript
exec codeObject in __main__.__dict__
File "C:\Fausto\Execs\Script.py", line 4, in ?
File "C:\PROGRAM FILES\PYTHON\lib\os.py", line 266, in execl
execv(file, args)
OSError: [Errno 2] No such file or directory
Naturally, as I am a Windows ME user, I have to make a
few changes to the code you suggest. My script then became:
import os
myPy = 'c:/fausto/execs/teste.exe'
os.execl('c:/windows/command.com', '/k', myPy)
But nothing but the error messages above have been
produced. Frustrating. :-(
Thanks, anyway.
---Fausto
walt <whrauser at erols.com> wrote:
> Fausto,
>
> 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/turtle.py'
> 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',
> myPy)
>
> But, I generally use the spawn series, since I want to return to my
> script after the program runs.
>
> Walt
More information about the Python-list
mailing list