Python 使cx_冻结以向初创公司添加应用程序
如何使cx_冻结以使创建的应用在windows启动时启动?我找不到像这样的问题的答案Python 使cx_冻结以向初创公司添加应用程序,python,python-3.x,cx-freeze,Python,Python 3.x,Cx Freeze,如何使cx_冻结以使创建的应用在windows启动时启动?我找不到像这样的问题的答案 就像启动时启动一样,我的意思是当计算机启动时,程序会自动启动。我还希望在首次使用该程序时自动执行此操作。您可以使用win32库创建exe的快捷方式,并将其放置在启动文件夹中 from win32com.client import Dispatch import os dir = r'C:\Users\<user name>\AppData\Roaming\Microsoft\Windows\Sta
就像启动时启动一样,我的意思是当计算机启动时,程序会自动启动。我还希望在首次使用该程序时自动执行此操作。您可以使用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()
从win32com.client导入分派
导入操作系统
dir=r'C:\Users\\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup'
name='shortcut.lnk'
path=os.path.join(dir,name)
目标=“”
工作目录=“”
图标=“”
shell=Dispatch('WScript.shell')
快捷方式=shell.CreateShortCut(路径)
快捷方式。Targetpath=target
shortcut.WorkingDirectory=工作目录
shortcut.IconLocation=图标
shortcut.save()
希望它是自动的。什么不是自动的?希望有一个代码可以将它添加到启动中。非自动部分来自于必须手动将程序添加到启动列表中。作为最佳实践,路径应该有r'
,或者避开反斜杠\\
,或者使用前斜杠/
编辑我的帖子:)