.msi 快捷方式 cx_Freeze

.msi Shortcut with cx_Freeze

我正在尝试用 cx_Freeze 为 Python 创建一个 .msi 3.I 可以创建 .msi 没问题,它安装正常并创建了一个快捷方式,但是快捷方式不起作用,因为快捷方式不在安装目录中 运行。非常感谢任何帮助或建议。

确保在构建分发包时设置了工作目录选项。 您可以制作一个 table,所有选项设置如下:

from cx_Freeze import *

shortcut_table = [
    ("DesktopShortcut",         # Shortcut
     "DesktopFolder",           # Directory_
     "appName_shortcut",                 # Name
     "TARGETDIR",               # Component_
     "[TARGETDIR]appName.exe",  # Target
     None,                      # Arguments
     None,                      # Description
     None,                      # Hotkey
     None,                      # Icon
     None,                      # IconIndex
     None,                      # ShowCmd
     'TARGETDIR'                # WkDir
     )
    ]
options = {
    'bdist_msi': {
        'data': {"Shortcut": shortcut_table},
    },
}
setup(
    name="appName",
    options=options,
    version="0.0.1",
    description='descr',
    executables=[Executable("appName.py", base=base,)]
)

您也可以像这样简单地将 shortCutNameshortcutDir 选项提供给 Executable:

from cx_Freeze import *

setup(
    executables = [
        Executable(
            "appName.py",
            shortcutName="appName_shortcut",
            shortcutDir="DesktopFolder",
            )
        ]
    )

基于 this 答案。