python --windows创建软链接(快捷方式)
- from win32com.client import Dispatch
-
- path = r"D:\mojoy.lnk" # Path to be saved (shortcut)
- target = r"D:\video_frame\mojoy\mojoy.exe" # The shortcut target file or folder
- work_dir = r"D:\video_frame\mojoy" # The parent folder of your file
- shell = Dispatch('WScript.Shell')
- shortcut = shell.CreateShortCut(path)
- shortcut.Targetpath = target
- shortcut.WorkingDirectory = work_dir
- shortcut.IconLocation = r"D:\code\windows_firewall\logo.ico" # 设置快捷方式的图标
- shortcut.Hotkey = "CTRL+ALT+M" # 这里设置了快捷键为 CTRL+ALT+M,您可以根据需要修改
- shortcut.save()
-