使用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)

转载于:https://www.cnblogs.com/luoheng23/p/11342479.html

你可能感兴趣的:(使用python创建文件快捷方式)