Python 3 script how do i add a shortcut to recently added in the windows 10 start menu?

261 Views Asked by At

I am currently running python 3.8. While I am able to add a shortcut to the script to the windows 10 start menu it does not show in recently added. I have also tried winshell.recent

import os, winshell
from win32com.client import Dispatch

Start_menu = winshell.start_menu()
path = os.path.join(Start_menu, "A test.lnk")
target = r"Python Project\test2.pyw"
wDir = r"Python Project"
icon = r"C:\\Users\\"+str(os.getlogin())+"\\Desktop\\Python Project\\icon.ico"

shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.WorkingDirectory = wDir
shortcut.IconLocation = icon
shortcut.save()
0

There are 0 best solutions below