Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use cx-freeze to create an msi that adds a shortcut to the desktop

I am using cx-freeze to create an MSI installer for a Python application. How can I install a link to the application from the desktop?

like image 888
joshuanapoli Avatar asked Mar 31 '13 21:03

joshuanapoli


People also ask

How do I create an installer shortcut?

Right-click on .exe file and choose to create a shortcut; Go to properties of the shortcut and select an icon and choose a meaningful name; Add the shortcut on User's Desktop and User's Programs Menu.

How do I create a shortcut in InstallShield?

Click the Launch Tutorial.exe icon. Leave the default setting, Create shortcut in Start menu, selected. InstallShield will create a shortcut to Tutorial.exe on the end user's Start menu when the installation is run.

What is cx_Freeze?

cx_Freeze is a set of scripts and modules for freezing Python scripts into executables, in much the same way that py2exe and py2app do. Unlike these two tools, cx_Freeze is cross-platform and should work on any platform that Python itself works on. It supports Python 2.7 or higher (including Python 3).


1 Answers

To create a shortcut to the application, give the shortCutName and shortcutDir options to the Executable. The shortcutDir can name any of the System Folder Properties (thanks Aaron). For example:

from cx_Freeze import *

setup(
    executables = [
        Executable(
            "MyApp.py",
            shortcutName="DTI Playlist",
            shortcutDir="DesktopFolder",
            )
        ]
    )

You can also add items to the MSI Shortcut table. This lets you create multiple shortcuts and set the working directory (the "start in" setting of the shortcut).

from cx_Freeze import *

# http://msdn.microsoft.com/en-us/library/windows/desktop/aa371847(v=vs.85).aspx
shortcut_table = [
    ("DesktopShortcut",        # Shortcut
     "DesktopFolder",          # Directory_
     "DTI Playlist",           # Name
     "TARGETDIR",              # Component_
     "[TARGETDIR]playlist.exe",# Target
     None,                     # Arguments
     None,                     # Description
     None,                     # Hotkey
     None,                     # Icon
     None,                     # IconIndex
     None,                     # ShowCmd
     'TARGETDIR'               # WkDir
     )
    ]

# Now create the table dictionary
msi_data = {"Shortcut": shortcut_table}

# Change some default MSI options and specify the use of the above defined tables
bdist_msi_options = {'data': msi_data}

setup(
    options = {
        "bdist_msi": bdist_msi_options,
    },
    executables = [
        Executable(
            "MyApp.py",
            )
        ]
    )
like image 148
joshuanapoli Avatar answered Sep 16 '22 13:09

joshuanapoli