How to create an entry in the "Program menu" of Windows?

sandro sandro at e-den.it
Wed Feb 2 03:56:05 EST 2011


Alexander Kapps wrote:

> On 01.02.2011 22:43, Diesel wrote:
>>
>> Hi,
>>
>> I'd like to add menu entry in the Program Menu as part of the
>> installation of an application. Is it possible to do that from Python?
>>
>> Any examples or link? I have not been able to find anything with
>> google...
>>
>> thanks in advance
>> s/
>>
>
> AFAIK, the startmenu entries are just .lnk files, placed either in 
> the "All Users" or "Some Specific User" Startmenu directory. I only 
> have a German XP and can't boot it to test at the moment, so I can't 
> give more details, but there are surely registry entries to find the 
> Startmenu location for the current user or for "All Users".
>
> See http://codesnippets.joyent.com/posts/show/529 for an example how 
> to place .lnk files. However, for real deployment, you probably want 
> to use a real installer framework like NSIS for example.
>

Thanks Alexander, in the meanwhile I also found this [1] message that
reports the following snippet that uses module winshell (and win32...):

[1] http://www.mail-archive.com/python-win32@python.org/msg05411.html

import os, sys
import winshell

startup = winshell.startup () # use common=1 for all users
print startup

winshell.CreateShortcut (
 Path=os.path.join (winshell.startup (), "Python.lnk"),
 Target=sys.executable,
 Icon=(sys.executable, 0),
 Description="Python"
)

thanks again
*:-)



More information about the Python-list mailing list