How can i save shortcut in python if target path conatains nonascii

32 Views Asked by At

If the path target path contains nonascii, saving getting failed if it contains ascii then it works.

def CreateShortcut(shortcutDir, shortcutName, targetPath, iconPath, iconIdx):
    pythoncom.CoInitialize()
    shll = Dispatch('WScript.Shell')
    shortcut = shll.CreateShortCut(shortcutDir.GetChild("%s.lnk" % shortcutName).path)
    shortcut.Targetpath = GetFolderShortPath(targetPath.path)
    shortcut.IconLocation = GetFileShortPath(iconPath.path)
    shortcut.save() 

in this shortcut failing to interpret path because it contains non ascii path , how could i resolve this

If i enable "Beta: Use Unicode UTF-8 for worldwide language support" then it works , what code changes should i make if i disable the beta checkbox and target path contains non ascii

0

There are 0 best solutions below