Small problem executing python script as shortcut

Jorgen Bodde jorgen.maillist at gmail.com
Thu Feb 7 11:16:05 EST 2008


Hi all,

This is slightly OT but it drives me nuts. Whenever I create a
shortcut in the start menu (in Windows) of a python script, it will
only execute it when the path where the script resides in contains no
spaces. For example;

d:\src\app\app.py

If I drag that to the Start Menu it can be executed fine.

Whenever I distribute my app and the path will become:

"c:\program files\app\app.py"

Windows will make spaces itself inside the shortcut so I guess it
realizes that it needs to execute the full string but probably
somewhere when resolving the app to execute the script with, the
double quotes get lost and the python interpreter (I use ActiveState
as my Python bundle) will only see "c:\program" as the first part and
doesn't pick up the latter.

I know I can write a batch script that runs the python script, but
since it is a wxPython app, I want to launch a *.pyw to suppress the
dos box. However as it seems now there is no way to create a shortcut
under windows to launch a python script when the directory contains
spaces in the name.

Does anyone know a solution? I would like to distribute my app both
with py2exe (no problems there) but also as source only version so
people can adjust the code if they wish.

Regards,
- Jorgen



More information about the Python-list mailing list