python - 使 cx_Freeze 将应用程序添加到初创公司

标签 python python-3.x cx-freeze

如何使 cx_Freeze 使创建的应用程序在 Windows 启动时启动?我找不到此类问题的答案。

正如启动时启动一样,我的意思是当计算机启动时,程序会自动启动。我还希望在第一次使用该程序时自动完成此操作。

最佳答案

您可以使用 win32 库创建 exe 的快捷方式并将其放置在启动文件夹中。

from win32com.client import Dispatch
import os

dir = r'C:\Users\<user name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup'
name = 'shortcut.lnk'
path = os.path.join(dir, name)
target = '<your exe>'
working_dir = '<working directory>'
icon = '<file to take the icon from, can be your exe>'

shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.WorkingDirectory = working_dir
shortcut.IconLocation = icon
shortcut.save()

关于python - 使 cx_Freeze 将应用程序添加到初创公司,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37045933/

相关文章:

python - 将 python 标志 cx_freeze 添加到可执行文件

python - 使用 cx_Freeze 的下一步是什么?

python - 同时填充 Pandas 数据框中相关列中的缺失值

django - "best"获取列表大小的方法

Python 3.3.4 Cx_Freeze 导入错误 : DDL load failed: The specified module could not be found

python - 有没有办法使用 scikit 或任何其他 python 包仅获取单词的 IDF 值?

python - 在类变量中引用类方法

python - AWS/Python Lambda 函数检查是否存在查询字符串

python - Seaborn FacetGrid KDE 值错误

regex - 用于匹配字符串的特定子字符串的正则表达式