如何从快捷方式lnk获取完整目标字符串

请我尝试从快捷方式文件中获取完整目标。 我正在使用以下function

Public Function GetLnkTarget(lnkPath As String) As String Dim Obj As Object Obj = CreateObject("WScript.Shell") Dim Shortcut As Object Shortcut = Obj.CreateShortcut(lnkPath) Return Shortcut.TargetPath.ToString End Function 

例如,我有一个带有以下目标的快捷方式.lnk文件:

 C:\WINDOWS\system32\wscript.exe /e:VBScript.Encode Folder/skype.exe 

当我使用该函数从以下.lnk D:\ Shortcut.lnk获取目标

 GetLnkTarget("D:\Shortcut.lnk") 

我得到以下输出

 C:\WINDOWS\system32\wscript.exe 

所以它不会返回Target的完整字符串,因为输出中缺少“/e:VBScript.Encode Folder / skype.exe”。

您需要访问Shortcut.Arguments属性。 请参阅此处以获取快捷方式对象的参考。

https://msdn.microsoft.com/en-us/library/f5y78918(v=vs.84).aspx

所以你的代码将是:

 Return Shortcut.TargetPath.ToString & " " & Shortcut.Arguments