python 创建快捷方式

标签:
python快捷方式winshellit |
分类: python |
winshell.deskTop()
指的是桌面
winshell.startup()
指启动项
target
指快捷方式所指向的文件。即需要调用的文件。
下面这个函数将创建程序自身的快捷方式到桌面:
from os import path
import winshell
def create_shortcut_to_desktop():
下面这个函数实现将本程序的快捷方式从桌面删除:
def delete_shortcut_from_startup():
from os import path
import winshell
def create_shortcut_to_startup():
下面是使用的demo:
-
#
-*-code: utf-8 -*- -
import
os -
import
winshell -
-
def
main(): -
destDir = winshell.desktop() -
filename = "myShortcut" -
target = r"D:\Python" -
-
winshell.CreateShortcut( -
Path = os.path.join(destDir, os.path.basename(filename)+".lnk"), -
Target = target, -
Icon = (target, 0), -
Description = "shortcut test" ) -
-
if
__name__ "__main__":== -
main()
前一篇:pyhook 安装
后一篇:python 获取当前路径