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?
Asked
Active
Viewed 1.5k times
18
-
possible duplicate of [Use cx-freeze to create an msi installer that installs a child installer](http://stackoverflow.com/questions/15733405/use-cx-freeze-to-create-an-msi-installer-that-installs-a-child-installer) – Rob Mensching Mar 31 '13 at 22:40
-
3The questions are different. In this question, I want to create a desktop icon. The other question asks about bundling several MSI installers. – joshuanapoli Apr 01 '13 at 13:30
1 Answers
36
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",
)
]
)

NameVergessen
- 598
- 8
- 26

joshuanapoli
- 2,509
- 3
- 25
- 34
-
Would you know how this works with a system administrator going to install such an app? They won't get the option for shortcuts or will they? – PascalVKooten Oct 23 '13 at 07:25
-
1The shortcut will be installed for all users if the ALLUSERS property is set. – joshuanapoli Nov 03 '13 at 20:50
-
Where can you set that ALLUSERS property? How do you specify an icon? – Craig McQueen Nov 20 '13 at 04:55
-
1One way to set ALLUSERS is to add "ALLUSERS=1" to the msiexec command line when installing the .MSI. – joshuanapoli Jan 25 '14 at 17:30
-
2Here's a list of Windows folders which you can use with shortcutDir: http://msdn.microsoft.com/en-us/library/aa370905(v=vs.85).aspx#System_Folder_Properties – Aaron Apr 30 '14 at 15:45
-
-
1@Har Yes, you can create multiple desktop shortcuts by adding multiple items to the shortcut_table list. Use a different "shortcut" name for each item. – joshuanapoli Feb 19 '15 at 02:27
-
Does somebody know how to set the icon for the shortcut? A string at the anotated line doesn't do the trick for me. – NameVergessen Nov 15 '22 at 18:31
-
At least in my case the absolut path was needed. Hope that for the shortcut icon. I hope that helps someone. – NameVergessen Nov 15 '22 at 18:47