Question: How to execute an EXE with Python?

Peter Hansen peter at
Tue Aug 27 23:05:05 EDT 2002

"Fausto Arinos de A. Barbuto" wrote:
> Hi Peter,
>     Now it is working: here is the code.
>     import os
>     os.chdir('c:/fausto/execs')
>     os.system('teste.exe')
>     That os.system('c:/fausto/execs/teste.exe') doesn't work.

Ah, James hit on the real problem.  While Python loves
forward slashes, and parts of Windows can even handle it,
the command interpreter does not like them at all, except
as option flags (where Unix mostly uses "-").

Thus this should have worked:


Note the "r" before the quotation marks.  Without that, you
would need to double up every backslash to avoid them being
interpreted as escape characters for the following character,
with things like "\t" becoming TAB characters, for example.


More information about the Python-list mailing list