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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM