K
K
Kovalskii2019-09-26 20:47:50
Python
Kovalskii, 2019-09-26 20:47:50

How to make a python app installer that creates an icon on the desktop?

I already have a compiled python application, but I need to make an installer for it.
I used NSIS script , pynsist and fbs to create the installer , but the last two use NSIS and only install program files in a user-specified folder.
Basically, there is no problem in making the NSIS installer install my application in Program Files, but I want to make a desktop icon as well.
Is there a way to do this through the same NSIS or through the pynsist script and how exactly?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
latush, 2019-09-26
@latush

Yes, there is through NSIS, I have done it many times

A
Alex_Zab, 2020-12-18
@Alex_Zab

This can be done while executing the program -

user_name = os.getlogin()
pythoncom.CoInitialize()
desktop = r'C:/Users/' + user_name + '/Desktop'
path = os.path.join(desktop, 'AppName.lnk')
target = path_to_file

shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.WindowStyle = 1   # 7 - Minimized, 3 - Maximized, 1 - Normal
shortcut.save()

Paste this code at the beginning of the program (but don't forget to fill in `AppName.lnk` and `path_to_file`)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question