Otman Beggas Otman Beggas - 10 months ago 60
Vb.net Question

How to get Full Target String from Shortcut lnk

Please i am trying to get the full target from a shortcut file. I am using the below 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

For example i have a shortcut .lnk file with the following target:

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

When i use the function to get the target from the following .lnk


i get the following output


So it does not return the full string of the Target as "/e:VBScript.Encode Folder/skype.exe" is missing from the output.


You need to access the Shortcut.Arguments property. See here for the reference of the shortcut object.


So your code will be:

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