My problem is that i can't find a solution to create a shortcut to an folder with python. Only to a file, code example:
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.save()
But I need a shortcut to a whole folder.
My target example is:
C:/Users
and C:/Users/user/Downloads
CodePudding user response:
You can use the below code to create shortcut to a directory
from win32com.client import Dispatch
path = r"C:\Users\user\Downloads\shortcut.lnk" #This is where the shortcut will be created
target = r"C:\Users\user\Downloads" # directory to which the shortcut is created
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.save()