首页 > 解决方案 > 创建快捷方式返回错误,但在其他计算机上工作正常

问题描述

我在 5 台计算机上运行此程序,4 台运行良好,但 1 台返回错误 在此处输入图像描述

这就是我的代码的样子

desktop = os.path.join(os.environ["HOMEPATH"], "Desktop")
shortcutpath = os.path.join(desktop, 'MeetingAssistant.lnk')
target = path + '\\MeetingAssistant.exe'
icon = imagefolder + '\\icon.ico'

time.sleep(1)
pythoncom.CoInitialize()
shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut(shortcutpath)
shortcut.WorkingDirectory = path
shortcut.Targetpath = target
shortcut.IconLocation = icon
shortcut.save() 

标签: pythonpython-3.x

解决方案


推荐阅读