Luke Luke - 1 year ago 152
Python Question

Make cx_Freeze to add app to startups

How can I make cx_Freeze to make the app created to start on windows startup? I can't find the answer to any questions like this.

As in start on startup, I mean when the computer boots, the program automatically starts. I also would like this to be done automatically in first use of the program.

Ni. Ni.
Answer Source

You can use win32 library to create a shortcut to your exe and place it in the startup folder.

from win32com.client import Dispatch
import os

dir = 'C:\Users\<user name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup'
name = 'shortcut.lnk'
path = os.path.join(dir, name)
target = '<your exe>'
wDir = '<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 = wDir
shortcut.IconLocation = icon
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download