【问题标题】:Use cx-freeze to create an msi that adds a shortcut to the desktop使用 cx-freeze 创建一个添加快捷方式到桌面的 msi
【发布时间】:2013-03-22 00:16:33
【问题描述】:

我正在使用 cx-freeze 为 Python 应用程序创建 MSI 安装程序。如何从桌面安装应用程序的链接?

【问题讨论】:

标签: windows-installer cx-freeze


【解决方案1】:

要创建应用程序的快捷方式,请将 shortCutNameshortcutDir 选项提供给可执行文件。 shortcutDir 可以命名任何System Folder Properties(感谢 Aaron)。例如:

from cx_Freeze import *

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

您还可以将项目添加到 MSI 快捷方式表。这使您可以创建多个快捷方式并设置工作目录(快捷方式的“开始”设置)。

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",
            )
        ]
    )

【讨论】:

  • 您知道系统管理员如何安装这样的应用程序吗?他们不会获得快捷方式的选项,还是会?
  • 如果设置了 ALLUSERS 属性,将为所有用户安装快捷方式。
  • 设置 ALLUSERS 的一种方法是在安装 .MSI 时将“ALLUSERS=1”添加到 msiexec 命令行。
  • 这里是 Windows 文件夹的列表,您可以将其与 shortcutDir 一起使用:msdn.microsoft.com/en-us/library/…
  • @Har 是的,您可以通过将多个项目添加到快捷方式表列表来创建多个桌面快捷方式。为每个项目使用不同的“快捷方式”名称。
猜你喜欢
  • 1970-01-01
  • 2013-03-14
  • 2012-08-05
  • 1970-01-01
  • 1970-01-01
  • 2011-06-21
  • 1970-01-01
  • 1970-01-01
  • 2014-01-21
相关资源
最近更新 更多