使用python创建文件快捷方式

import os
import win32com.client as client

shell = client.Dispatch("WScript.Shell")

def GetShortCut(shortcut):
    return shell.CreateShortCut(shortcut).Targetpath

def createShortCut(filename, lnkname):
    """filename should be abspath, or there will be some strange errors"""
    shortcut = shell.CreateShortCut(lnkname)
    shortcut.TargetPath = filename
    shortcut.save()

def CreateShortCut(filename, lnkname):
    createShortCut(os.path.abspath(filename), lnkname)
posted @ 2019-08-12 20:48  luoheng  阅读(4537)  评论(2编辑  收藏  举报