By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,617 Members | 1,751 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,617 IT Pros & Developers. It's quick & easy.

Small problem executing python script as shortcut

P: n/a
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
Feb 7 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Jorgen Bodde wrote:
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
Sure there is. Just put double quotes around the entire Target and Start in
entries in the shortcut.

Example:
Target: "C:\Program Files\WebSafe\WStools\WSsend.exe"
Start in: "C:\Program Files\WebSafe\WStools\"

Suggestions:

1) Download Inno Installer and wrap your distribution into a proper installation
(setup.exe) program. It takes care of all this for you.

2) Take a look at py2exe to bundle your entire application up so that you don't
need python on the machine at all.

Hope info helps.

-Larry
Feb 7 '08 #2

P: n/a
Hi Larry,

Sorry for accidentally mailing you personally. I fixed the problem, it
was a problem with the search path, and once that was fixed it works
fine!

thanks again,
- Jorgen

On Feb 8, 2008 9:26 AM, Jorgen Bodde <jo*************@gmail.comwrote:
Hi Larry,
Sure there is. Just put double quotes around the entire Target and Start in
entries in the shortcut.

That is exacty the problem. The shortcut (if dropped on the start menu
even by hand or by Inno Installer) already has those quotes. Still, it
is mpossible to launch a python script that way so it seems.
Example:
Target: "C:\Program Files\WebSafe\WStools\WSsend.exe"
Start in: "C:\Program Files\WebSafe\WStools\"

As I already explained, the windows shortcut is already formatted like that
1) Download Inno Installer and wrap your distribution into a proper installation
(setup.exe) program. It takes care of all this for you.

it's actually the same with inno setup. A python script like
c:\Program Files\app\app.py won't start. Could you please verify this
for me? Simply make a subdir in Program Files and put a python script
in there. Then drag and drop this script as a shortcut on the start
menu. Then try to execute it. This does not seem to work
2) Take a look at py2exe to bundle your entire application up so that you don't
need python on the machine at all.

Like explained, I would like to offer both. Source based install and
exe based, so people who are into python can view the code, and
contribute if needed. I always like it when I get the choice to modify
the app when there are small issues with it that I can easly resolve.

thanks for your reply!
- Jorgen


Hope info helps.

-Larry
--
http://mail.python.org/mailman/listinfo/python-list
Feb 8 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.