python - 用python创建windows快捷方式到“程序文件”
问题描述
使用下面的代码,我可以创建快捷方式。
问题是当我尝试创建一个指向“程序文件”的快捷方式时。生成的快捷方式将始终将 Target 设置为“ Program Files (x86) ”。
import os
import pythoncom
from win32com.shell import shell
shortcut = pythoncom.CoCreateInstance(
shell.CLSID_ShellLink,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink
)
path = "C:\Program Files\ConEmu\ConEmu64.exe"
shortcut.SetPath(path)
shortcut.SetIconLocation(path, 0)
persist_file = shortcut.QueryInterface(pythoncom.IID_IPersistFile)
persist_file.Save(os.path.join(os.getcwd(), "conEmu.lnk"), 0))
甚至很难我将路径设置为: C:\Program Files\ConEmu\ConEmu64.exe
出于某种原因,快捷方式有: C:\Program Files (x86)\ConEmu\ConEmu64.exe
我也试过:
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
结果相同。
解决方案
推荐阅读
- javascript - jQueryUI datepicker 不显示下一个以前的三角形箭头
- performance - Angular 5 应用程序需要很长时间才能为初次使用的用户加载,我需要帮助来加快速度
- c - 为什么用 papi 读取硬件计数器的结果取决于 PAPI_library_init 位置?
- terraform - Terraform 远程状态使用不正确的文件
- php - 使用 PHP 保留文件属性压缩文件夹
- ruby-on-rails - 在远程 SSL 代理后面使用 Rails config.force_ssl 进行无限重定向
- gradle - 如何避免在运行 gradle 任务时创建构建目录?
- file - 如何从base64字符串下载文件以反应本机?
- asp.net - asp.net Web 表单 (VB) 页面从 SQL 呈现不正确的数据
- protractor - 如何使用量角器找到桌面视图的汉堡图标?