如何使 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/