How to set shortcut working directory in cx_freeze msi bundle?

前端 未结 2 911
死守一世寂寞
死守一世寂寞 2021-01-03 12:40

I was working on a Python program which deals with SQLite3 databases. I made it as an MSI setup file by using cx_Freeze.

Windows shortcuts produced by .msi set-up fi

2条回答
  •  花落未央
    2021-01-03 13:43

    Found the solution in the answer to another question. Essentially, one needs to set up the shortcut table data. The last 'TARGETDIR' in the shortcut_table below sets up the working directory to be the installation directory.

    ---copied from above mentioned answer---

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

提交回复
热议问题