vb 如何用代码修改快捷方式的链接对像

2024-11-26 13:26:09
推荐回答(1个)
回答1:

'以下代码可以满足你的要求:

Dim WshShell As Object, WScript As Object, oShellLink As Object
Set WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop") '桌面路径
Set oShellLink = WshShell.CreateShortcut(strDesktop & "\1.lnk") '打开快捷方式
oShellLink.TargetPath = "c:\2.exe" '修改文件路径
oShellLink.Save '保存快捷方式
Set WshShell = Nothing
Set oShellLink = Nothing