J
J
Jomm2021-06-20 00:09:54
Python
Jomm, 2021-06-20 00:09:54

How to make a shortcut using python?

I want to make a shortcut leading to the file so that I can then throw it into autoload

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Endora Blackwell, 2021-06-20
@Jomm

You can try like this

import os
from win32com.client import Dispatch

path = os.path.join("Путь, куда сохранять", "Name.lnk")

target = r"Полный путь к файлу"
wDir   = r"Путь к папке с файлом"
icon   = r"Путь к иконке с файлом (Можно к .exe)"

shell    = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)

shortcut.Targetpath       = target
shortcut.WorkingDirectory = wDir
shortcut.IconLocation     = icon

shortcut.save()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question