1

I'm creating a single file exe for my Python program. I'm using cx_Freeze. Everything works perfect except one little annoying thing.

When I install my program everything installs as it should do, including the shortcut on my desktop.

BUT...When I want to start the program with the shortcut on the desktop I get the following error:

Error

When I try to run my program from within my program folder than it works. When I manually create a shortcut to the desktop than it works aswell.

Does anyone know why the shortcut, which is installed at the installation of my program doesn't work?

My cx_Freeze setup.py

import cx_Freeze
import sys

executables = [cx_Freeze.Executable("Tennis_Calculator.py", base="Win32GUI", icon="tennis_ball.ico", shortcutName="TPC", shortcutDir="DesktopFolder")]
build_exe_options = {"icon": "tennis_ball.ico","packages":["Tkinter", "csv", "ttk"], "include_files":["tennis_ball.ico", "testtennis.csv"]}
build_msi_options = {"include_files":"testtennis.csv"}


cx_Freeze.setup(
    name = "Tennis Probability Calculator",
    options = {"build_exe":build_exe_options, "build_msi":build_msi_options},
    version = "1.0",
    author = "WS",

    executables = executables
    )
MAYANK SHARMA
  • 307
  • 1
  • 4
  • 12
Wouter
  • 173
  • 15

1 Answers1

1

After a long search I found a solution.

How to set shortcut working directory in cx_freeze msi bundle?

I was able to fix the problem by making a small change to cx_Freeze/windist.py. In add_config(), line 61, I changed:

msilib.add_data(self.db, "Shortcut",
        [("S_APP_%s" % index, executable.shortcutDir,
                executable.shortcutName, "TARGETDIR",
                "[TARGETDIR]%s" % baseName, None, None, None,
                None, None, None, None)])

to

msilib.add_data(self.db, "Shortcut",
        [("S_APP_%s" % index, executable.shortcutDir,
                executable.shortcutName, "TARGETDIR",
                "[TARGETDIR]%s" % baseName, None, None, None,
                None, None, None, "TARGETDIR")]) # <--- Working directory.

Thanks everyone.

Community
  • 1
  • 1
Wouter
  • 173
  • 15