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

Westley Martínez anikom15 at gmail.com
Wed Feb 2 01:25:35 CET 2011


distutils can do this with a post-install script. See the distutils
documentation.
This is a script I wrote that did this (and other stuff):
import sys
import os

if sys.argv[1] == '-install':
    # Append .py to scripts
    os.rename(os.path.join(sys.prefix, 'Scripts', 'anikom15'),
              os.path.join(sys.prefix, 'Scripts', 'anikom15.py'))
    file_created(os.path.join(sys.prefix, 'Scripts', 'anikom15.py'))
    # Create desktop and start menu shortcuts
    desktop = get_special_folder_path("CSIDL_COMMON_DESKTOPDIRECTORY")
    startmenu = get_special_folder_path("CSIDL_COMMON_STARTMENU")
    create_shortcut(os.path.join(sys.prefix, 'Scripts', 'anikom15.py'),
                    "Launch Anikom15's Computer Game",
                    os.path.join(desktop, 'Anikom15.lnk'),
                    '', '',
                    os.path.join(sys.prefix, 'Icons', 'anikom15.ico'))
    file_created(os.path.join(desktop, 'Anikom15.lnk'))
    create_shortcut(os.path.join(sys.prefix, 'Scripts', 'anikom15.py'),
                    "Anikom15's Computer Game",
                    os.path.join(startmenu, 'Anikom15.lnk'),
                    '', '',
                    os.path.join(sys.prefix, 'Icons', 'anikom15.ico'))
    file_created(os.path.join(startmenu, 'Anikom15.lnk'))
elif sys.argv[1] == '-remove':
    pass

On Tue, 2011-02-01 at 21:43 +0000, 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/
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110201/b2d76ebb/attachment.html>


More information about the Python-list mailing list