其他分享
首页 > 其他分享> > PyInstallerImportError: Failed to load dynlib/dll 打包好的exe可以正常运行,但是exe产生的快捷方式却无法启动

PyInstallerImportError: Failed to load dynlib/dll 打包好的exe可以正常运行,但是exe产生的快捷方式却无法启动

作者:互联网


#解决方法:创建的快捷方式需要添加起始位置 StartIn=str(target).replace(s, "")
import winshell
import os
def create_shortcut_to_desktop():
target = sys.argv[0]
title = 'XX快捷方式'
s = os.path.basename(target)
fname = os.path.splitext(s)[0]
winshell.CreateShortcut(
Path=os.path.join(winshell.desktop(), fname + '.lnk'),
StartIn=str(target).replace(s, ""),
Target=target,
Icon=(target, 0),
Description=title)

def delete_shortcut_from_startup():
target = sys.argv[0]
s = os.path.basename(target)
fname = os.path.splitext(s)[0]
# delfile = micpath.join(winshell.startup(), fname + '.lnk')
delfile = os.path.join(winshell.desktop(), fname + '.lnk')
if os.path.exists(delfile):
winshell.delete_file(delfile)

标签:load,exe,target,delfile,fname,winshell,path,快捷方式,os
来源: https://www.cnblogs.com/archer-mowei/p/15703305.html