[python-win32] shortcut creation during installation

Mark Hammond mhammond at skippinet.com.au
Thu Sep 16 01:13:29 CEST 2004


> The first link try to launch python with a script as
> argument, so values are :
>
> target=os.path.join(sys.exec_prefix,"python.exe")
> description="..."
> shortcut=os.path.join(some_dir,"mylink.lnk")
> arguments="path_to_myscript.py"
>
> and finally
> create_shortcut(target,description,shortcut,arguments)
>
> This creates a link but when it is activated, it tells
> "C:\Python23\python.exe is not a valid Win32 application."
> This sounds like the problem is coming from the file
> C:\Python23\python.exe and not from the shortcut I just
> create. Is something wrong with the way I make the link ?

That looks fine to me, so I am surprised.  Did you try looking at the link
properties in Windows, and seeing what they said?  Try getting the link to
work from windows to see what went wrong and transfer that back to the code.

Also, look for win32com\shell\test\link.py - it creates links from "first
principals".

> My second link starts Acrobat reader with a file as argument.
> This time, values are :
>
> target=os.path.join(
>        "C:\\Program Files\\Adobe\\Acrobat 5.\\Acrobat",
>        "Acrobat.exe")
> description="..."
> shortcut=os.path.join(some_dir,"Mydocumentpdf.lnk")
> arguments="path_to_doc.pdf"
>
> create_shortcut(target,description,shortcut,arguments)
>
> This works fine! :)
> But my path to acrobat reader (i.e. in target) may not be the
> same for an other windows user.
> Is there a way to find the path to the executable of a
> program ? (something similar to get_special_folder_path ...)

I vaguely recall you can just set the path to the PDF - and Windows takes
care of the rest.  If not, win32api.FindExecutable is what you need.

Mark



More information about the Python-win32 mailing list