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

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

from cx_Freeze import *

setup(
    executables = [
        Executable(
            "MyApp.py",
            shortcut_name="DTI Playlist",
            shortcut_dir="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 that will be show on the link
     "TARGETDIR",              # Component_
     "[TARGETDIR]playlist.exe",# Target exe to exexute
     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",
            )
        ]
    )

Leave a Comment

tech