On 7/04/2012 12:57 AM, Cesar Covarrubias wrote:
I'm still getting my feet wet on the Windows side of things with Python,
so I apologize for the noobish question.

If i am reading the create_link.py example correctly, that is created
when the application itself is invoked, not during installation. Is that
correct? If it is, how would I be able to invoke that when generating
the MSI so that the installer creates the shortcut?

Right - I think I misunderstood your question. If you can't arrange for install.py to run then what I suggested isn't going to help that.

Note however that bdist_msi really isn't targeted at creating stand-alone installations, but instead at installing Python extension modules. I'd recommend using cx_Freeze to create the app, but looking further afield to create the installer for the app (eg, Inno, NSIS, WiX, etc)

Mark


Cesar

On Thu, Apr 5, 2012 at 8:42 PM, Mark Hammond <skippy.hamm...@gmail.com
<mailto:skippy.hamm...@gmail.com>> wrote:

    Seeing you are relying on win32com, you might as well add the links
    directly rather than via the intermediate WScript.shell object.
      Look in win32comext\shell\demos\__create_link.py for an example of
    how to create shortcuts directly.

    HTH,

    Mark

    On 6/04/2012 5:23 AM, cesar.covarrub...@gmail.com
    <mailto:cesar.covarrub...@gmail.com> wrote:

        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()







--
Very Respectfully,
Cesar Covarrubias





--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to