3

我目前正在运行 python 3.8。虽然我可以将脚本的快捷方式添加到 Windows 10 开始菜单,但它不会在最近添加的菜单中显示。我也试过 winshell.recent

import os, winshell
from win32com.client import Dispatch

Start_menu = winshell.start_menu()
path = os.path.join(Start_menu, "A test.lnk")
target = r"Python Project\test2.pyw"
wDir = r"Python Project"
icon = r"C:\\Users\\"+str(os.getlogin())+"\\Desktop\\Python Project\\icon.ico"

shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.WorkingDirectory = wDir
shortcut.IconLocation = icon
shortcut.save()
4

0 回答 0