Generating custom Windows installers

Discussion in 'Python' started by cesar.covarrubias@gmail.com, Apr 5, 2012.

  1. Guest

    Hello,

    I am working on creating an installer of a Python 3.2 application that we programmed. The end goal is to create an installer in which we can specify the install path, and create shortcuts in the Start Menu and Desktop. Ideally, we would like to give the users the option to create the Desktop or Start Menu shortcuts.

    I was able to create a .msi file with the setup.py and install.py files below. This allowed me to specify the custom default path but not create the shortcut in the Start Menu.

    Can anyone help me figure out what I'm missing?


    setup.py
    --------

    from cx_Freeze import setup, Executable
    import sys

    productName = "ProductName"
    if 'bdist_msi' in sys.argv:
    sys.argv += ['--initial-target-dir', 'C:\InstallDir\\' + productName]
    sys.argv += ['--install-script', 'install.py']

    exe = Executable(
    script="main.py",
    base="Win32GUI",
    targetName="Product.exe"
    )
    setup(
    name="Product.exe",
    version="1.0",
    author="Me",
    description="Copyright 2012",
    executables=[exe],
    scripts=[
    'install.py'
    ]
    )
    -----------------------------------------

    install.py
    ----------
    import os
    import sys
    import win32com.client as w32client

    shortcut_group_name = "Start Menu Dir"
    shortcut_name = "Product Name"
    shortcut_target = "http://www.microsoft.com"

    sh = w32client.Dispatch("WScript.Shell")
    p = sh.SpecialFolders("AllUsersPrograms")
    assert(os.path.isdir(p))
    p = os.path.join(p, shortcut_group_name)
    if (not os.path.isdir(p)):
    os.makedirs(p)
    lnk = sh.CreateShortcut(os.path.join(p, shortcut_name + ".lnk"))
    lnk.TargetPath = shortcut_target
    lnk.Save()
    , Apr 5, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Elmegaard

    distutils for non-python windows installers

    Brian Elmegaard, Oct 27, 2004, in forum: Python
    Replies:
    3
    Views:
    426
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Oct 29, 2004
  2. SPE - Stani's Python Editor

    Built windows installers and Cygwin

    SPE - Stani's Python Editor, Nov 23, 2005, in forum: Python
    Replies:
    1
    Views:
    374
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Nov 23, 2005
  3. imageguy
    Replies:
    1
    Views:
    577
    Martin v. Löwis
    Apr 4, 2008
  4. Darren Dale
    Replies:
    0
    Views:
    309
    Darren Dale
    Jun 29, 2008
  5. Acrive
    Replies:
    2
    Views:
    164
    Acrive
    Jun 20, 2010
Loading...

Share This Page