With Pywin32, can you do whatever you like on Windows?
Yes.
#-*-coding:cp936-*-# import osimport pythoncomfrom Win32com.shell import shellfrom Win32com.shell import shellcondef Set_shortcut (filename,lnkname,iconname): #如无需特别设置图标, you can remove the iconname parameter shortcut = pythoncom. CoCreateInstance (Shell. Clsid_shelllink, None, pythoncom. Clsctx_inproc_server, Shell. Iid_ishelllink) shortcut. SetPath (filename) shortcut. Seticonlocation (iconname,0) #可有可无, does not use the default file itself icon if Os.path.splitext (lnkname) [-1]! = '. Lnk ': Lnkname + = ". Lnk" Shortcut. QueryInterface (Pythoncom. Iid_ipersistfile). Save (lnkname,0) If __name__ = = "__main__": #获取 "Startup" folder path, the key is the final parameter csidl_startup, these parameters can be found in Microsoft's official API Startup_path = s Hell. SHGetPathFromIDList (shell. SHGetSpecialFolderLocation (0,shellcon. Csidl_startup)) #获取 the "desktop" folder path, change the last parameter to csidl_desktop Desktop_path = Shell. SHGetPathFromIDList (shell. SHGetSpecialFolderLocation (0,shellcon. Csidl_desktop) file_name= "" #要创建快捷方式的文件的完整路径 icon_name= "" #图标文件的完整路径 (not required) lnk_name1= startup_path+ "\ \ My desktop shortcut. lnk" #将要在此路径Create Shortcut lnk_name2= startup_path+ "\ \ My startup group shortcut. Lnk" Set_shortcut (file_name,lnk_name1,icon_name) set_shortcut (file_na Me,lnk_name2,icon_name)
Python Create Shortcut