如何在 cx_freeze msi 包中设置快捷工作目录? [英] How to set shortcut working directory in cx_freeze msi bundle?
问题描述
我正在开发一个处理 SQLite3 数据库的 Python 程序.我使用 cx_Freeze 将其制作为 MSI 安装文件.
I was working on a Python program which deals with SQLite3 databases. I made it as an MSI setup file by using cx_Freeze.
由 cx_Freeze 生成的 .msi 设置文件生成的 Windows 快捷方式不提供快捷方式的工作目录属性.因此,当我使用桌面上创建的快捷方式运行可执行文件时,它会在桌面上创建数据库文件.
Windows shortcuts produced by .msi set-up files generated by cx_Freeze do not provide the working directory property of the shortcut. Thus, when I run the executable using the shortcut created on the desktop, it's creating database files on the desktop itself.
这可以通过为快捷方式提供不同的工作目录来更改.我该怎么做?
This can be changed by providing a different working directory to the shortcut. How do I do that?
推荐答案
我能够通过对 cx_Freeze/windist.py 进行一些小改动来解决这个问题.在 add_config(),第 61 行,我更改了:
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)])
到
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.
谢谢大家.
这篇关于如何在 cx_freeze msi 包中设置快捷工作目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!